mirror of https://github.com/tc39/test262.git
Add tests for Dataview.prototype.getInt8
This commit is contained in:
parent
5e767dc2bb
commit
1567b685e2
53
test/built-ins/DataView/prototype/getInt8/byteoffset-is-different-integer-throws.js
vendored
Normal file
53
test/built-ins/DataView/prototype/getInt8/byteoffset-is-different-integer-throws.js
vendored
Normal file
|
@ -0,0 +1,53 @@
|
|||
// 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.getint8
|
||||
es6id: 24.2.4.7
|
||||
description: >
|
||||
Throws a RangeError if numberIndex ≠ getIndex
|
||||
info: |
|
||||
24.2.4.7 DataView.prototype.getInt8 ( byteOffset )
|
||||
|
||||
1. Let v be the this value.
|
||||
2. Return ? GetViewValue(v, byteOffset, true, "Int8").
|
||||
|
||||
24.2.1.1 GetViewValue ( view, requestIndex, isLittleEndian, type )
|
||||
|
||||
...
|
||||
4. Let numberIndex be ? ToNumber(requestIndex).
|
||||
5. Let getIndex be ToInteger(numberIndex).
|
||||
6. If numberIndex ≠ getIndex or getIndex < 0, throw a RangeError exception.
|
||||
...
|
||||
---*/
|
||||
|
||||
var buffer = new ArrayBuffer(12);
|
||||
var sample = new DataView(buffer, 0);
|
||||
|
||||
assert.throws(RangeError, function() {
|
||||
sample.getInt8();
|
||||
}, "no args");
|
||||
|
||||
assert.throws(RangeError, function() {
|
||||
sample.getInt8(undefined);
|
||||
}, "undefined");
|
||||
|
||||
assert.throws(RangeError, function() {
|
||||
sample.getInt8(1.1);
|
||||
}, "floating number");
|
||||
|
||||
assert.throws(RangeError, function() {
|
||||
sample.getInt8(0.1);
|
||||
}, "0.1");
|
||||
|
||||
assert.throws(RangeError, function() {
|
||||
sample.getInt8(NaN);
|
||||
}, "NaN");
|
||||
|
||||
assert.throws(RangeError, function() {
|
||||
sample.getInt8(-0.1);
|
||||
}, "-0.1");
|
||||
|
||||
assert.throws(RangeError, function() {
|
||||
sample.getInt8(-1.1);
|
||||
}, "-1.1");
|
|
@ -0,0 +1,33 @@
|
|||
// 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.getint8
|
||||
es6id: 24.2.4.7
|
||||
description: >
|
||||
Throws a RangeError if getIndex < 0
|
||||
info: |
|
||||
24.2.4.7 DataView.prototype.getInt8 ( byteOffset )
|
||||
|
||||
1. Let v be the this value.
|
||||
2. Return ? GetViewValue(v, byteOffset, true, "Int8").
|
||||
|
||||
24.2.1.1 GetViewValue ( view, requestIndex, isLittleEndian, type )
|
||||
|
||||
...
|
||||
4. Let numberIndex be ? ToNumber(requestIndex).
|
||||
5. Let getIndex be ToInteger(numberIndex).
|
||||
6. If numberIndex ≠ getIndex or getIndex < 0, throw a RangeError exception.
|
||||
...
|
||||
---*/
|
||||
|
||||
var buffer = new ArrayBuffer(12);
|
||||
var sample = new DataView(buffer, 0);
|
||||
|
||||
assert.throws(RangeError, function() {
|
||||
sample.getInt8(-1);
|
||||
}, "-1");
|
||||
|
||||
assert.throws(RangeError, function() {
|
||||
sample.getInt8(-Infinity);
|
||||
}, "-Infinity");
|
37
test/built-ins/DataView/prototype/getInt8/detached-buffer-after-integer-byteoffset.js
vendored
Normal file
37
test/built-ins/DataView/prototype/getInt8/detached-buffer-after-integer-byteoffset.js
vendored
Normal 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.getint8
|
||||
es6id: 24.2.4.7
|
||||
description: >
|
||||
Detached buffer is checked after checking If numberIndex ≠ getIndex or
|
||||
getIndex < 0,
|
||||
info: |
|
||||
24.2.4.7 DataView.prototype.getInt8 ( byteOffset )
|
||||
|
||||
1. Let v be the this value.
|
||||
2. Return ? GetViewValue(v, byteOffset, true, "Int8").
|
||||
|
||||
24.2.1.1 GetViewValue ( view, requestIndex, isLittleEndian, type )
|
||||
|
||||
...
|
||||
6. If numberIndex ≠ getIndex or getIndex < 0, throw a RangeError exception.
|
||||
...
|
||||
8. Let buffer be the value of view's [[ViewedArrayBuffer]] internal slot.
|
||||
9. If IsDetachedBuffer(buffer) is true, throw a TypeError exception.
|
||||
...
|
||||
includes: [detachArrayBuffer.js]
|
||||
---*/
|
||||
|
||||
var buffer = new ArrayBuffer(8);
|
||||
var sample = new DataView(buffer, 0);
|
||||
|
||||
$DETACHBUFFER(buffer);
|
||||
assert.throws(RangeError, function() {
|
||||
sample.getInt8(1.1);
|
||||
});
|
||||
|
||||
assert.throws(RangeError, function() {
|
||||
sample.getInt8(-1);
|
||||
});
|
39
test/built-ins/DataView/prototype/getInt8/detached-buffer-before-outofrange-byteoffset.js
vendored
Normal file
39
test/built-ins/DataView/prototype/getInt8/detached-buffer-before-outofrange-byteoffset.js
vendored
Normal 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.getint8
|
||||
es6id: 24.2.4.7
|
||||
description: >
|
||||
Detached buffer is checked before out of range byteOffset's value
|
||||
info: |
|
||||
24.2.4.7 DataView.prototype.getInt8 ( byteOffset )
|
||||
|
||||
1. Let v be the this value.
|
||||
2. Return ? GetViewValue(v, byteOffset, true, "Int8").
|
||||
|
||||
24.2.1.1 GetViewValue ( view, requestIndex, isLittleEndian, type )
|
||||
|
||||
...
|
||||
8. Let buffer be the value of view's [[ViewedArrayBuffer]] internal slot.
|
||||
9. If IsDetachedBuffer(buffer) is true, throw a TypeError exception.
|
||||
...
|
||||
13. 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.getInt8(Infinity);
|
||||
}, "Infinity");
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
sample.getInt8(13);
|
||||
}, "13");
|
|
@ -0,0 +1,30 @@
|
|||
// 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.getint8
|
||||
es6id: 24.2.4.7
|
||||
description: >
|
||||
Throws a TypeError if buffer is detached
|
||||
info: |
|
||||
24.2.4.7 DataView.prototype.getInt8 ( byteOffset )
|
||||
|
||||
1. Let v be the this value.
|
||||
2. Return ? GetViewValue(v, byteOffset, true, "Int8").
|
||||
|
||||
24.2.1.1 GetViewValue ( view, requestIndex, isLittleEndian, type )
|
||||
|
||||
...
|
||||
8. Let buffer be the value of view's [[ViewedArrayBuffer]] internal slot.
|
||||
9. 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.getInt8(0);
|
||||
});
|
|
@ -0,0 +1,61 @@
|
|||
// 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.getint8
|
||||
es6id: 24.2.4.7
|
||||
description: >
|
||||
Throws a RangeError if getIndex + elementSize > viewSize
|
||||
info: |
|
||||
24.2.4.7 DataView.prototype.getInt8 ( byteOffset )
|
||||
|
||||
1. Let v be the this value.
|
||||
2. Return ? GetViewValue(v, byteOffset, true, "Int8").
|
||||
|
||||
24.2.1.1 GetViewValue ( view, requestIndex, isLittleEndian, type )
|
||||
|
||||
...
|
||||
10. Let viewOffset be the value of view's [[ByteOffset]] internal slot.
|
||||
11. Let viewSize be the value of view's [[ByteLength]] internal slot.
|
||||
12. Let elementSize be the Number value of the Element Size value specified in
|
||||
Table 50 for Element Type type.
|
||||
13. If getIndex + elementSize > viewSize, throw a RangeError exception.
|
||||
...
|
||||
---*/
|
||||
|
||||
var sample;
|
||||
var buffer = new ArrayBuffer(12);
|
||||
|
||||
sample = new DataView(buffer, 0);
|
||||
|
||||
assert.throws(RangeError, function() {
|
||||
sample.getInt8(Infinity);
|
||||
}, "getIndex == Infinity");
|
||||
|
||||
assert.throws(RangeError, function() {
|
||||
sample.getInt8(13);
|
||||
}, "13 + 1 > 12");
|
||||
|
||||
assert.throws(RangeError, function() {
|
||||
sample.getInt8(12);
|
||||
}, "12 + 1 > 12");
|
||||
|
||||
sample = new DataView(buffer, 11);
|
||||
assert.throws(RangeError, function() {
|
||||
sample.getInt8(1);
|
||||
}, "1 + 1 > 1 (offset)");
|
||||
|
||||
sample = new DataView(buffer, 0, 1);
|
||||
assert.throws(RangeError, function() {
|
||||
sample.getInt8(1);
|
||||
}, "1 + 1 > 1 (length)");
|
||||
|
||||
sample = new DataView(buffer, 4, 1);
|
||||
assert.throws(RangeError, function() {
|
||||
sample.getInt8(1);
|
||||
}, "1 + 1 > 1 (offset+length)");
|
||||
|
||||
sample = new DataView(buffer, 4, 0);
|
||||
assert.throws(RangeError, function() {
|
||||
sample.getInt8(0);
|
||||
}, "0 + 1 > 0 (offset+length)");
|
30
test/built-ins/DataView/prototype/getInt8/return-abrupt-from-tonumber-byteoffset-symbol.js
vendored
Normal file
30
test/built-ins/DataView/prototype/getInt8/return-abrupt-from-tonumber-byteoffset-symbol.js
vendored
Normal file
|
@ -0,0 +1,30 @@
|
|||
// 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.getint8
|
||||
es6id: 24.2.4.7
|
||||
description: >
|
||||
Return abrupt from ToNumber(symbol byteOffset)
|
||||
info: |
|
||||
24.2.4.7 DataView.prototype.getInt8 ( byteOffset )
|
||||
|
||||
1. Let v be the this value.
|
||||
2. Return ? GetViewValue(v, byteOffset, true, "Int8").
|
||||
|
||||
24.2.1.1 GetViewValue ( view, requestIndex, isLittleEndian, type )
|
||||
|
||||
...
|
||||
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.getInt8(s);
|
||||
});
|
43
test/built-ins/DataView/prototype/getInt8/return-abrupt-from-tonumber-byteoffset.js
vendored
Normal file
43
test/built-ins/DataView/prototype/getInt8/return-abrupt-from-tonumber-byteoffset.js
vendored
Normal 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.getint8
|
||||
es6id: 24.2.4.7
|
||||
description: >
|
||||
Return abrupt from ToNumber(byteOffset)
|
||||
info: |
|
||||
24.2.4.7 DataView.prototype.getInt8 ( byteOffset )
|
||||
|
||||
1. Let v be the this value.
|
||||
2. Return ? GetViewValue(v, byteOffset, true, "Int8").
|
||||
|
||||
24.2.1.1 GetViewValue ( view, requestIndex, isLittleEndian, type )
|
||||
|
||||
...
|
||||
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.getInt8(bo1);
|
||||
}, "valueOf");
|
||||
|
||||
assert.throws(Test262Error, function() {
|
||||
sample.getInt8(bo2);
|
||||
}, "toString");
|
|
@ -0,0 +1,36 @@
|
|||
// 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.getint8
|
||||
es6id: 24.2.4.7
|
||||
description: >
|
||||
Return value from Buffer using a clean ArrayBuffer
|
||||
info: |
|
||||
24.2.4.7 DataView.prototype.getInt8 ( byteOffset )
|
||||
|
||||
1. Let v be the this value.
|
||||
2. Return ? GetViewValue(v, byteOffset, true, "Int8").
|
||||
|
||||
24.2.1.1 GetViewValue ( view, requestIndex, isLittleEndian, type )
|
||||
|
||||
...
|
||||
14. Let bufferIndex be getIndex + viewOffset.
|
||||
15. Return GetValueFromBuffer(buffer, bufferIndex, type, isLittleEndian).
|
||||
...
|
||||
|
||||
24.1.1.5 GetValueFromBuffer ( arrayBuffer, byteIndex, type [ , isLittleEndian
|
||||
] )
|
||||
|
||||
...
|
||||
8. If isLittleEndian is false, reverse the order of the elements of rawValue.
|
||||
...
|
||||
---*/
|
||||
|
||||
var buffer = new ArrayBuffer(4);
|
||||
var sample = new DataView(buffer, 0);
|
||||
|
||||
assert.sameValue(sample.getInt8(0), 0, "sample.getInt8(0)");
|
||||
assert.sameValue(sample.getInt8(1), 0, "sample.getInt8(1)");
|
||||
assert.sameValue(sample.getInt8(2), 0, "sample.getInt8(2)");
|
||||
assert.sameValue(sample.getInt8(3), 0, "sample.getInt8(3)");
|
61
test/built-ins/DataView/prototype/getInt8/return-values-coerced-byteoffset.js
vendored
Normal file
61
test/built-ins/DataView/prototype/getInt8/return-values-coerced-byteoffset.js
vendored
Normal file
|
@ -0,0 +1,61 @@
|
|||
// 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.getint8
|
||||
es6id: 24.2.4.7
|
||||
description: >
|
||||
Return values using coerced ToInteger byteOffset values
|
||||
info: |
|
||||
24.2.4.7 DataView.prototype.getInt8 ( byteOffset )
|
||||
|
||||
1. Let v be the this value.
|
||||
2. Return ? GetViewValue(v, byteOffset, true, "Int8").
|
||||
|
||||
24.2.1.1 GetViewValue ( view, requestIndex, isLittleEndian, type )
|
||||
|
||||
...
|
||||
14. Let bufferIndex be getIndex + viewOffset.
|
||||
15. Return GetValueFromBuffer(buffer, bufferIndex, type, isLittleEndian).
|
||||
...
|
||||
|
||||
24.1.1.5 GetValueFromBuffer ( arrayBuffer, byteIndex, type [ , isLittleEndian
|
||||
] )
|
||||
|
||||
...
|
||||
8. If isLittleEndian is false, reverse the order of the elements of rawValue.
|
||||
...
|
||||
features: [DataView.prototype.setUint8]
|
||||
---*/
|
||||
|
||||
var buffer = new ArrayBuffer(2);
|
||||
var sample = new DataView(buffer, 0);
|
||||
|
||||
sample.setUint8(0, 39);
|
||||
sample.setUint8(1, 42);
|
||||
|
||||
assert.sameValue(sample.getInt8(""), 39, "''");
|
||||
|
||||
assert.sameValue(sample.getInt8("0"), 39, "'0'");
|
||||
|
||||
assert.sameValue(sample.getInt8("1"), 42, "'1'");
|
||||
|
||||
var obj1 = {
|
||||
valueOf: function() {
|
||||
return 1;
|
||||
}
|
||||
};
|
||||
assert.sameValue(sample.getInt8(obj1), 42, "{}.valueOf");
|
||||
|
||||
var obj2 = {
|
||||
toString: function() {
|
||||
return 1;
|
||||
}
|
||||
};
|
||||
assert.sameValue(sample.getInt8(obj2), 42, "{}.toString");
|
||||
|
||||
assert.sameValue(sample.getInt8(true), 42, "true");
|
||||
|
||||
assert.sameValue(sample.getInt8(false), 39, "false");
|
||||
|
||||
assert.sameValue(sample.getInt8(null), 39, "null");
|
|
@ -0,0 +1,48 @@
|
|||
// 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.getint8
|
||||
es6id: 24.2.4.7
|
||||
description: >
|
||||
Return values from Buffer using a custom offset
|
||||
info: |
|
||||
24.2.4.7 DataView.prototype.getInt8 ( byteOffset )
|
||||
|
||||
1. Let v be the this value.
|
||||
2. Return ? GetViewValue(v, byteOffset, true, "Int8").
|
||||
|
||||
24.2.1.1 GetViewValue ( view, requestIndex, isLittleEndian, type )
|
||||
|
||||
...
|
||||
14. Let bufferIndex be getIndex + viewOffset.
|
||||
15. Return GetValueFromBuffer(buffer, bufferIndex, type, isLittleEndian).
|
||||
...
|
||||
|
||||
24.1.1.5 GetValueFromBuffer ( arrayBuffer, byteIndex, type [ , isLittleEndian
|
||||
] )
|
||||
|
||||
...
|
||||
8. If isLittleEndian is false, reverse the order of the elements of rawValue.
|
||||
...
|
||||
features: [DataView.prototype.setUint8]
|
||||
---*/
|
||||
|
||||
var buffer = new ArrayBuffer(8);
|
||||
var sample = new DataView(buffer, 0);
|
||||
|
||||
sample.setUint8(0, 7);
|
||||
sample.setUint8(1, 7);
|
||||
sample.setUint8(2, 7);
|
||||
sample.setUint8(3, 7);
|
||||
sample.setUint8(4, 1);
|
||||
sample.setUint8(5, 127);
|
||||
sample.setUint8(6, 128);
|
||||
sample.setUint8(7, 255);
|
||||
|
||||
sample = new DataView(buffer, 4);
|
||||
|
||||
assert.sameValue(sample.getInt8(0), 1);
|
||||
assert.sameValue(sample.getInt8(1), 127);
|
||||
assert.sameValue(sample.getInt8(2), -128);
|
||||
assert.sameValue(sample.getInt8(3), -1);
|
|
@ -0,0 +1,42 @@
|
|||
// 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.getint8
|
||||
es6id: 24.2.4.7
|
||||
description: >
|
||||
Return values from Buffer
|
||||
info: |
|
||||
24.2.4.7 DataView.prototype.getInt8 ( byteOffset )
|
||||
|
||||
1. Let v be the this value.
|
||||
2. Return ? GetViewValue(v, byteOffset, true, "Int8").
|
||||
|
||||
24.2.1.1 GetViewValue ( view, requestIndex, isLittleEndian, type )
|
||||
|
||||
...
|
||||
14. Let bufferIndex be getIndex + viewOffset.
|
||||
15. Return GetValueFromBuffer(buffer, bufferIndex, type, isLittleEndian).
|
||||
...
|
||||
|
||||
24.1.1.5 GetValueFromBuffer ( arrayBuffer, byteIndex, type [ , isLittleEndian
|
||||
] )
|
||||
|
||||
...
|
||||
8. If isLittleEndian is false, reverse the order of the elements of rawValue.
|
||||
...
|
||||
features: [DataView.prototype.setUint8]
|
||||
---*/
|
||||
|
||||
var buffer = new ArrayBuffer(4);
|
||||
var sample = new DataView(buffer, 0);
|
||||
|
||||
sample.setUint8(0, 127);
|
||||
sample.setUint8(1, 255);
|
||||
sample.setUint8(2, 0);
|
||||
sample.setUint8(3, 1);
|
||||
|
||||
assert.sameValue(sample.getInt8(0), 127);
|
||||
assert.sameValue(sample.getInt8(1), -1);
|
||||
assert.sameValue(sample.getInt8(2), 0);
|
||||
assert.sameValue(sample.getInt8(3), 1);
|
|
@ -0,0 +1,42 @@
|
|||
// 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.getint8
|
||||
es6id: 24.2.4.7
|
||||
description: >
|
||||
Throws a TypeError if this does not have a [[DataView]] internal slot
|
||||
info: |
|
||||
24.2.4.7 DataView.prototype.getInt8 ( byteOffset )
|
||||
|
||||
1. Let v be the this value.
|
||||
2. Return ? GetViewValue(v, byteOffset, true, "Int8").
|
||||
|
||||
24.2.1.1 GetViewValue ( view, requestIndex, isLittleEndian, type )
|
||||
|
||||
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 getInt8 = DataView.prototype.getInt8;
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
getInt8.call({});
|
||||
}, "{}");
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
getInt8.call([]);
|
||||
}, "[]");
|
||||
|
||||
var ab = new ArrayBuffer(1);
|
||||
assert.throws(TypeError, function() {
|
||||
getInt8.call(ab);
|
||||
}, "ArrayBuffer");
|
||||
|
||||
var ta = new Int8Array();
|
||||
assert.throws(TypeError, function() {
|
||||
getInt8.call(ta);
|
||||
}, "TypedArray");
|
|
@ -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.getint8
|
||||
es6id: 24.2.4.7
|
||||
description: Throws a TypeError if this is not Object
|
||||
info: |
|
||||
24.2.4.7 DataView.prototype.getInt8 ( byteOffset )
|
||||
|
||||
1. Let v be the this value.
|
||||
2. Return ? GetViewValue(v, byteOffset, true, "Int8").
|
||||
|
||||
24.2.1.1 GetViewValue ( view, requestIndex, isLittleEndian, type )
|
||||
|
||||
1. If Type(view) is not Object, throw a TypeError exception.
|
||||
...
|
||||
features: [Symbol]
|
||||
---*/
|
||||
|
||||
var getInt8 = DataView.prototype.getInt8;
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
getInt8.call(undefined);
|
||||
}, "undefined");
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
getInt8.call(null);
|
||||
}, "null");
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
getInt8.call(1);
|
||||
}, "1");
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
getInt8.call("string");
|
||||
}, "string");
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
getInt8.call(true);
|
||||
}, "true");
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
getInt8.call(false);
|
||||
}, "false");
|
||||
|
||||
var s = Symbol("1");
|
||||
assert.throws(TypeError, function() {
|
||||
getInt8.call(s);
|
||||
}, "symbol");
|
Loading…
Reference in New Issue