-
Notifications
You must be signed in to change notification settings - Fork 464
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1284 from cxielarko/getbigint64
DataView.prototype.getBigInt64 tests
- Loading branch information
Showing
17 changed files
with
709 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
test/built-ins/DataView/prototype/getBigInt64/detached-buffer-after-toindex-byteoffset.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// Copyright (C) 2017 Igalia, S.L. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
|
||
/*--- | ||
esid: sec-dataview.prototype.getbigint64 | ||
description: > | ||
Detached buffer is only checked after ToIndex(requestIndex) | ||
info: | | ||
DataView.prototype.getBigInt64 ( byteOffset [ , littleEndian ] ) | ||
1. Let v be the this value. | ||
2. If littleEndian is not present, let littleEndian be undefined. | ||
3. Return ? GetViewValue(v, byteOffset, littleEndian, "Int64"). | ||
24.3.1.1 GetViewValue ( view, requestIndex, isLittleEndian, type ) | ||
... | ||
4. Let getIndex be ? ToIndex(requestIndex). | ||
... | ||
6. Let buffer be view.[[ViewedArrayBuffer]]. | ||
7. If IsDetachedBuffer(buffer) is true, throw a TypeError exception. | ||
... | ||
includes: [detachArrayBuffer.js] | ||
features: [DataView, ArrayBuffer, BigInt, arrow-function] | ||
---*/ | ||
|
||
var buffer = new ArrayBuffer(8); | ||
var sample = new DataView(buffer, 0); | ||
|
||
$DETACHBUFFER(buffer); | ||
|
||
assert.throws(RangeError, () => sample.getBigInt64(Infinity), | ||
"DataView access at index Infinity should throw"); | ||
|
||
assert.throws(RangeError, () => sample.getBigInt64(-1), | ||
"DataView access at index -1 should throw"); |
35 changes: 35 additions & 0 deletions
35
.../built-ins/DataView/prototype/getBigInt64/detached-buffer-before-outofrange-byteoffset.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// Copyright (C) 2017 Igalia, S.L. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
|
||
/*--- | ||
esid: sec-dataview.prototype.getbigint64 | ||
description: > | ||
Detached buffer is checked before out of range byteOffset's value | ||
info: | | ||
24.2.4.8 DataView.prototype.getBigInt64 ( byteOffset [ , littleEndian ] ) | ||
1. Let v be the this value. | ||
2. If littleEndian is not present, let littleEndian be undefined. | ||
3. Return ? GetViewValue(v, byteOffset, littleEndian, "Int64"). | ||
24.3.1.1 GetViewValue ( view, requestIndex, isLittleEndian, type ) | ||
... | ||
6. Let buffer be view.[[ViewedArrayBuffer]]. | ||
7. If IsDetachedBuffer(buffer) is true, throw a TypeError exception. | ||
... | ||
11. If getIndex + elementSize > viewSize, throw a RangeError exception. | ||
... | ||
includes: [detachArrayBuffer.js] | ||
features: [DataView, ArrayBuffer, BigInt, arrow-function] | ||
---*/ | ||
|
||
var sample; | ||
var buffer = new ArrayBuffer(12); | ||
|
||
sample = new DataView(buffer, 0); | ||
|
||
$DETACHBUFFER(buffer); | ||
|
||
assert.throws(TypeError, () => sample.getBigInt64(13), | ||
"detached DataView access should throw"); |
30 changes: 30 additions & 0 deletions
30
test/built-ins/DataView/prototype/getBigInt64/detached-buffer.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// Copyright (C) 2017 Igalia, S.L. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
|
||
/*--- | ||
esid: sec-dataview.prototype.getbigint64 | ||
description: > | ||
Throws a TypeError if buffer is detached | ||
info: | | ||
DataView.prototype.getBigInt64 ( byteOffset [ , littleEndian ] ) | ||
1. Let v be the this value. | ||
2. If littleEndian is not present, let littleEndian be undefined. | ||
3. Return ? GetViewValue(v, byteOffset, littleEndian, "Int64"). | ||
24.3.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] | ||
features: [DataView, ArrayBuffer, BigInt, arrow-function] | ||
---*/ | ||
|
||
var buffer = new ArrayBuffer(1); | ||
var sample = new DataView(buffer, 0); | ||
|
||
$DETACHBUFFER(buffer); | ||
assert.throws(TypeError, () => sample.getBigInt64(0), | ||
"detached DataView access should throw"); |
75 changes: 75 additions & 0 deletions
75
test/built-ins/DataView/prototype/getBigInt64/index-is-out-of-range.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
// Copyright (C) 2017 Igalia, S.L. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
|
||
/*--- | ||
esid: sec-dataview.prototype.getbigint64 | ||
description: > | ||
Throws a RangeError if getIndex + elementSize > viewSize | ||
info: | | ||
DataView.prototype.getBigInt64 ( byteOffset [ , littleEndian ] ) | ||
1. Let v be the this value. | ||
2. If littleEndian is not present, let littleEndian be undefined. | ||
3. Return ? GetViewValue(v, byteOffset, littleEndian, "Int64"). | ||
24.3.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. | ||
... | ||
features: [DataView, ArrayBuffer, BigInt, arrow-function] | ||
---*/ | ||
|
||
var sample; | ||
var buffer = new ArrayBuffer(12); | ||
|
||
sample = new DataView(buffer, 0); | ||
|
||
assert.throws(RangeError, () => sample.getBigInt64(Infinity), | ||
"DataView access at index Infinity should throw"); | ||
|
||
assert.throws(RangeError, () => sample.getBigInt64(13), "13 + 8 > 12"); | ||
|
||
assert.throws(RangeError, () => sample.getBigInt64(12), "12 + 8 > 12"); | ||
|
||
assert.throws(RangeError, () => sample.getBigInt64(11), "11 + 8 > 12"); | ||
|
||
assert.throws(RangeError, () => sample.getBigInt64(10), "10 + 8 > 12"); | ||
|
||
assert.throws(RangeError, () => sample.getBigInt64(9), "9 + 8 > 12"); | ||
|
||
assert.throws(RangeError, () => sample.getBigInt64(8), "8 + 8 > 12"); | ||
|
||
assert.throws(RangeError, () => sample.getBigInt64(7), "7 + 8 > 12"); | ||
|
||
assert.throws(RangeError, () => sample.getBigInt64(6), "6 + 8 > 12"); | ||
|
||
assert.throws(RangeError, () => sample.getBigInt64(5), "5 + 8 > 12"); | ||
|
||
sample = new DataView(buffer, 8); | ||
assert.throws(RangeError, () => sample.getBigInt64(1), | ||
"1 + 8 > 4 (offset)"); | ||
|
||
sample = new DataView(buffer, 9); | ||
assert.throws(RangeError, () => sample.getBigInt64(0), | ||
"0 + 8 > 3 (offset)"); | ||
|
||
sample = new DataView(buffer, 0, 8); | ||
assert.throws(RangeError, () => sample.getBigInt64(1), | ||
"1 + 8 > 8 (length)"); | ||
|
||
sample = new DataView(buffer, 0, 7); | ||
assert.throws(RangeError, () => sample.getBigInt64(0), | ||
"0 + 8 > 7 (length)"); | ||
|
||
sample = new DataView(buffer, 4, 8); | ||
assert.throws(RangeError, () => sample.getBigInt64(1), | ||
"1 + 8 > 8 (offset+length)"); | ||
|
||
sample = new DataView(buffer, 4, 7); | ||
assert.throws(RangeError, () => sample.getBigInt64(0), | ||
"0 + 8 > 7 (offset+length)"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// Copyright (C) 2017 Igalia, S.L. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
|
||
/*--- | ||
esid: sec-dataview.prototype.getbigint64 | ||
description: DataView.prototype.getBigInt64.length property descriptor | ||
info: > | ||
DataView.prototype.getBigInt64 ( byteOffset [ , littleEndian ] ) | ||
17 ECMAScript Standard Built-in Objects | ||
Every built-in function object, including constructors, has a length | ||
property whose value is an integer. Unless otherwise specified, this | ||
value is equal to the largest number of named arguments shown in the | ||
subclause headings for the function description. Optional parameters | ||
(which are indicated with brackets: [ ]) or rest parameters (which | ||
are shown using the form «...name») are not included in the default | ||
argument count. | ||
Unless otherwise specified, the length property of a built-in | ||
function object has the attributes { [[Writable]]: false, | ||
[[Enumerable]]: false, [[Configurable]]: true }. | ||
includes: [propertyHelper.js] | ||
features: [DataView, ArrayBuffer, BigInt] | ||
---*/ | ||
|
||
verifyProperty(DataView.prototype.getBigInt64, "length", { | ||
value: 1, | ||
writable: false, | ||
enumerable: false, | ||
configurable: true | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// Copyright (C) 2017 Igalia, S.L. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
|
||
/*--- | ||
esid: sec-dataview.prototype.getbigint64 | ||
description: DataView.prototype.getBigInt64.name property descriptor | ||
info: > | ||
DataView.prototype.getBigInt64 ( byteOffset [ , littleEndian ] ) | ||
17 ECMAScript Standard Built-in Objects | ||
Every built-in function object, including constructors, that is not | ||
identified as an anonymous function has a name property whose value | ||
is a String. Unless otherwise specified, this value is the name that | ||
is given to the function in this specification. For functions that | ||
are specified as properties of objects, the name value is the | ||
property name string used to access the function. [...] | ||
Unless otherwise specified, the name property of a built-in function | ||
object, if it exists, has the attributes { [[Writable]]: false, | ||
[[Enumerable]]: false, [[Configurable]]: true }. | ||
includes: [propertyHelper.js] | ||
features: [DataView, ArrayBuffer, BigInt] | ||
---*/ | ||
|
||
verifyProperty(DataView.prototype.getBigInt64, "name", { | ||
value: "getBigInt64", | ||
writable: false, | ||
enumerable: false, | ||
configurable: true | ||
}); |
30 changes: 30 additions & 0 deletions
30
test/built-ins/DataView/prototype/getBigInt64/negative-byteoffset-throws.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// Copyright (C) 2017 Igalia, S.L. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
|
||
/*--- | ||
esid: sec-dataview.prototype.getbigint64 | ||
description: > | ||
Throws a RangeError if getIndex < 0 | ||
info: | | ||
DataView.prototype.getBigInt64 ( byteOffset [ , littleEndian ] ) | ||
1. Let v be the this value. | ||
2. If littleEndian is not present, let littleEndian be undefined. | ||
3. Return ? GetViewValue(v, byteOffset, littleEndian, "Int64"). | ||
24.3.1.1 GetViewValue ( view, requestIndex, isLittleEndian, type ) | ||
... | ||
4. Let getIndex be ? ToIndex(requestIndex). | ||
... | ||
features: [DataView, ArrayBuffer, BigInt, arrow-function] | ||
---*/ | ||
|
||
var buffer = new ArrayBuffer(12); | ||
var sample = new DataView(buffer, 0); | ||
|
||
assert.throws(RangeError, () => sample.getBigInt64(-1), | ||
"DataView access at index -1 should throw"); | ||
|
||
assert.throws(RangeError, () => sample.getBigInt64(-Infinity), | ||
"DataView access at index -Infinity should throw"); |
28 changes: 28 additions & 0 deletions
28
...built-ins/DataView/prototype/getBigInt64/return-abrupt-from-tonumber-byteoffset-symbol.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// Copyright (C) 2017 Igalia, S.L. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
|
||
/*--- | ||
esid: sec-dataview.prototype.getbigint64 | ||
description: > | ||
Return abrupt from ToNumber(symbol byteOffset) | ||
info: | | ||
DataView.prototype.getBigInt64 ( byteOffset [ , littleEndian ] ) | ||
1. Let v be the this value. | ||
2. If littleEndian is not present, let littleEndian be undefined. | ||
3. Return ? GetViewValue(v, byteOffset, littleEndian, "Int64"). | ||
24.3.1.1 GetViewValue ( view, requestIndex, isLittleEndian, type ) | ||
... | ||
4. Let getIndex be ? ToNumber(requestIndex). | ||
... | ||
features: [DataView, ArrayBuffer, Symbol, BigInt, arrow-function] | ||
---*/ | ||
|
||
var buffer = new ArrayBuffer(1); | ||
var sample = new DataView(buffer, 0); | ||
|
||
var s = Symbol("1"); | ||
|
||
assert.throws(TypeError, () => sample.getBigInt64(s)); |
31 changes: 31 additions & 0 deletions
31
test/built-ins/DataView/prototype/getBigInt64/return-abrupt-from-tonumber-byteoffset.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// Copyright (C) 2017 Igalia, S.L. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
|
||
/*--- | ||
esid: sec-dataview.prototype.getbigint64 | ||
description: > | ||
Return abrupt from ToNumber(byteOffset) | ||
info: | | ||
DataView.prototype.getBigInt64 ( byteOffset [ , littleEndian ] ) | ||
1. Let v be the this value. | ||
2. If littleEndian is not present, let littleEndian be undefined. | ||
3. Return ? GetViewValue(v, byteOffset, littleEndian, "Int64"). | ||
24.3.1.1 GetViewValue ( view, requestIndex, isLittleEndian, type ) | ||
... | ||
4. Let getIndex be ? ToNumber(requestIndex). | ||
... | ||
features: [DataView, ArrayBuffer, BigInt, arrow-function] | ||
---*/ | ||
|
||
var buffer = new ArrayBuffer(1); | ||
var sample = new DataView(buffer, 0); | ||
|
||
var bo1 = { valueOf() { throw new Test262Error(); } }; | ||
var bo2 = { toString() { throw new Test262Error(); } }; | ||
|
||
assert.throws(Test262Error, () => sample.getBigInt64(bo1), "valueOf"); | ||
|
||
assert.throws(Test262Error, () => sample.getBigInt64(bo2), "toString"); |
Oops, something went wrong.