-
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 #1316 from cxielarko/setbigint64
setBigInt64 tests
- Loading branch information
Showing
21 changed files
with
639 additions
and
0 deletions.
There are no files selected for viewing
20 changes: 20 additions & 0 deletions
20
test/built-ins/DataView/prototype/setBigInt64/detached-buffer-after-bigint-value.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,20 @@ | ||
// 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.setbigint64 | ||
description: > | ||
Detached buffer is checked after ToBigInt(value) | ||
includes: [detachArrayBuffer.js] | ||
features: [DataView, ArrayBuffer, BigInt] | ||
---*/ | ||
|
||
var buffer = new ArrayBuffer(8); | ||
var sample = new DataView(buffer, 0); | ||
|
||
var v = { valueOf() { throw new Test262Error(); } }; | ||
|
||
$DETACHBUFFER(buffer); | ||
assert.throws(Test262Error, function() { | ||
sample.setBigInt64(0, v); | ||
}); |
23 changes: 23 additions & 0 deletions
23
test/built-ins/DataView/prototype/setBigInt64/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,23 @@ | ||
// 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.setbigint64 | ||
description: > | ||
Detached buffer is only checked after ToIndex(requestIndex) | ||
includes: [detachArrayBuffer.js] | ||
features: [DataView, ArrayBuffer, BigInt] | ||
---*/ | ||
|
||
var buffer = new ArrayBuffer(12); | ||
var sample = new DataView(buffer, 0); | ||
|
||
$DETACHBUFFER(buffer); | ||
|
||
assert.throws(RangeError, function() { | ||
sample.setBigInt64(Infinity, 0); | ||
}, "DataView access at index Infinity should throw"); | ||
|
||
assert.throws(RangeError, function() { | ||
sample.setBigInt64(-1, 0); | ||
}, "DataView access at index -1 should throw"); |
21 changes: 21 additions & 0 deletions
21
.../built-ins/DataView/prototype/setBigInt64/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,21 @@ | ||
// 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.setbigint64 | ||
description: > | ||
Detached buffer is checked before out of range byteOffset's value | ||
includes: [detachArrayBuffer.js] | ||
features: [DataView, ArrayBuffer, BigInt] | ||
---*/ | ||
|
||
var sample; | ||
var buffer = new ArrayBuffer(12); | ||
|
||
sample = new DataView(buffer, 0); | ||
|
||
$DETACHBUFFER(buffer); | ||
|
||
assert.throws(TypeError, function() { | ||
sample.setBigInt64(13, 0); | ||
}, "detached DataView access should throw"); |
18 changes: 18 additions & 0 deletions
18
test/built-ins/DataView/prototype/setBigInt64/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,18 @@ | ||
// 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.setbigint64 | ||
description: > | ||
Throws a TypeError if buffer is detached | ||
includes: [detachArrayBuffer.js] | ||
features: [DataView, ArrayBuffer, BigInt] | ||
---*/ | ||
|
||
var buffer = new ArrayBuffer(1); | ||
var sample = new DataView(buffer, 0); | ||
|
||
$DETACHBUFFER(buffer); | ||
assert.throws(TypeError, function() { | ||
sample.setBigInt64(0, 0n); | ||
}); |
32 changes: 32 additions & 0 deletions
32
test/built-ins/DataView/prototype/setBigInt64/index-check-before-value-conversion.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,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.setbigint64 | ||
description: > | ||
RangeError exception for negative or non-integral index is thrown before | ||
the value conversion. | ||
features: [DataView, ArrayBuffer, BigInt] | ||
---*/ | ||
|
||
var dataView = new DataView(new ArrayBuffer(8), 0); | ||
|
||
var poisoned = { | ||
valueOf() { throw new Test262Error("valueOf called"); } | ||
}; | ||
|
||
assert.throws(RangeError, function() { | ||
dataView.setBigInt64(-1.5, poisoned); | ||
}, "setBigInt64(-1.5, poisoned)"); | ||
|
||
assert.throws(RangeError, function() { | ||
dataView.setBigInt64(-1, poisoned); | ||
}, "setBigInt64(-1, poisoned)"); | ||
|
||
assert.throws(RangeError, function() { | ||
dataView.setBigInt64(-Infinity, poisoned); | ||
}, "setBigInt64(-Infinity, poisoned)"); | ||
|
||
assert.throws(RangeError, function() { | ||
dataView.setBigInt64(Infinity, poisoned); | ||
}, "setBigInt64(Infinity, poisoned)"); |
88 changes: 88 additions & 0 deletions
88
test/built-ins/DataView/prototype/setBigInt64/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,88 @@ | ||
// 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.setbigint64 | ||
description: > | ||
Throws a RangeError if getIndex + elementSize > viewSize | ||
features: [DataView, ArrayBuffer, BigInt] | ||
---*/ | ||
|
||
var sample; | ||
var buffer = new ArrayBuffer(12); | ||
|
||
sample = new DataView(buffer, 0); | ||
|
||
assert.throws(RangeError, function() { | ||
sample.setBigInt64(Infinity, 39n); | ||
}, "getIndex == Infinity"); | ||
|
||
assert.throws(RangeError, function() { | ||
sample.setBigInt64(13, 39n); | ||
}, "13 + 8 > 12"); | ||
|
||
assert.throws(RangeError, function() { | ||
sample.setBigInt64(12, 39n); | ||
}, "12 + 8 > 12"); | ||
|
||
assert.throws(RangeError, function() { | ||
sample.setBigInt64(11, 39n); | ||
}, "11 + 8 > 12"); | ||
|
||
assert.throws(RangeError, function() { | ||
sample.setBigInt64(10, 39n); | ||
}, "10 + 8 > 12"); | ||
|
||
assert.throws(RangeError, function() { | ||
sample.setBigInt64(9, 39n); | ||
}, "9 + 8 > 12"); | ||
|
||
assert.throws(RangeError, function() { | ||
sample.setBigInt64(8, 39n); | ||
}, "8 + 8 > 12"); | ||
|
||
assert.throws(RangeError, function() { | ||
sample.setBigInt64(7, 39n); | ||
}, "7 + 8 > 12"); | ||
|
||
assert.throws(RangeError, function() { | ||
sample.setBigInt64(6, 39n); | ||
}, "6 + 8 > 12"); | ||
|
||
assert.throws(RangeError, function() { | ||
sample.setBigInt64(5, 39n); | ||
}, "5 + 8 > 12"); | ||
|
||
sample = new DataView(buffer, 8); | ||
assert.throws(RangeError, function() { | ||
sample.setBigInt64(1, 39n); | ||
}, "1 + 8 > 4 (offset)"); | ||
|
||
sample = new DataView(buffer, 9); | ||
assert.throws(RangeError, function() { | ||
sample.setBigInt64(0, 39n); | ||
}, "0 + 8 > 3 (offset)"); | ||
|
||
sample = new DataView(buffer, 0, 8); | ||
assert.throws(RangeError, function() { | ||
sample.setBigInt64(1, 39n); | ||
}, "1 + 8 > 8 (length)"); | ||
|
||
sample = new DataView(buffer, 0, 7); | ||
assert.throws(RangeError, function() { | ||
sample.setBigInt64(0, 39n); | ||
}, "0 + 8 > 7 (length)"); | ||
|
||
sample = new DataView(buffer, 4, 8); | ||
assert.throws(RangeError, function() { | ||
sample.setBigInt64(1, 39n); | ||
}, "1 + 8 > 8 (offset+length)"); | ||
|
||
sample = new DataView(buffer, 4, 7); | ||
assert.throws(RangeError, function() { | ||
sample.setBigInt64(0, 39n); | ||
}, "0 + 8 > 7 (offset+length)"); | ||
|
||
sample = new DataView(buffer, 0); | ||
assert.sameValue(sample.getBigInt64(0), 0n, "[0] no value was set"); | ||
assert.sameValue(sample.getBigInt64(4), 0n, "[1] no value was set"); |
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,16 @@ | ||
// 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.setbigint64 | ||
description: DataView.prototype.setBigInt64.length property descriptor | ||
includes: [propertyHelper.js] | ||
features: [DataView, ArrayBuffer, BigInt] | ||
---*/ | ||
|
||
verifyProperty(DataView.prototype.setBigInt64, "length", { | ||
value: 2, | ||
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,16 @@ | ||
// 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.setbigint64 | ||
description: DataView.prototype.setBigInt64.name property descriptor | ||
includes: [propertyHelper.js] | ||
features: [DataView, ArrayBuffer, BigInt] | ||
---*/ | ||
|
||
verifyProperty(DataView.prototype.setBigInt64, "name", { | ||
value: "setBigInt64", | ||
writable: false, | ||
enumerable: false, | ||
configurable: true | ||
}); |
22 changes: 22 additions & 0 deletions
22
test/built-ins/DataView/prototype/setBigInt64/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,22 @@ | ||
// 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.setbigint64 | ||
description: > | ||
Throws a RangeError if getIndex < 0 | ||
features: [DataView, ArrayBuffer, BigInt] | ||
---*/ | ||
|
||
var buffer = new ArrayBuffer(12); | ||
var sample = new DataView(buffer, 0); | ||
|
||
assert.throws(RangeError, function() { | ||
sample.setBigInt64(-1, 39n); | ||
}, "DataView access at index -1 should throw"); | ||
assert.sameValue(sample.getBigInt64(0), 0n, "-1 - no value was set"); | ||
|
||
assert.throws(RangeError, function() { | ||
sample.setBigInt64(-Infinity, 39n); | ||
}, "DataView access at index -Infinity should throw"); | ||
assert.sameValue(sample.getBigInt64(0), 0n, "-Infinity - no value was set"); |
14 changes: 14 additions & 0 deletions
14
test/built-ins/DataView/prototype/setBigInt64/no-value-arg.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,14 @@ | ||
// 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.setbigint64 | ||
description: > | ||
Set value as undefined (cast to 0) when value argument is not present | ||
features: [DataView, ArrayBuffer, BigInt, arrow-function] | ||
---*/ | ||
|
||
var buffer = new ArrayBuffer(8); | ||
var sample = new DataView(buffer, 0); | ||
|
||
assert.throws(TypeError, () => sample.setBigInt64(0)); |
21 changes: 21 additions & 0 deletions
21
test/built-ins/DataView/prototype/setBigInt64/range-check-after-value-conversion.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,21 @@ | ||
// 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.setbigint64 | ||
description: > | ||
Index bounds checks are performed after value conversion. | ||
features: [DataView, ArrayBuffer, BigInt] | ||
---*/ | ||
|
||
var dataView = new DataView(new ArrayBuffer(8), 0); | ||
|
||
var poisoned = { valueOf() { throw new Test262Error(); } }; | ||
|
||
assert.throws(Test262Error, function() { | ||
dataView.setBigInt64(100, poisoned); | ||
}, "setBigInt64(100, poisoned)"); | ||
|
||
assert.throws(Test262Error, function() { | ||
dataView.setBigInt64('100', poisoned); | ||
}, "setBigInt64('100', poisoned)"); |
18 changes: 18 additions & 0 deletions
18
test/built-ins/DataView/prototype/setBigInt64/return-abrupt-from-tobigint-value-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,18 @@ | ||
// 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.setbigint64 | ||
description: > | ||
Return abrupt from ToBigInt(symbol value) | ||
features: [DataView, ArrayBuffer, Symbol, BigInt] | ||
---*/ | ||
|
||
var buffer = new ArrayBuffer(8); | ||
var sample = new DataView(buffer, 0); | ||
|
||
var s = Symbol("1"); | ||
|
||
assert.throws(TypeError, function() { | ||
sample.setBigInt64(0, s); | ||
}); |
23 changes: 23 additions & 0 deletions
23
test/built-ins/DataView/prototype/setBigInt64/return-abrupt-from-tobigint-value.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,23 @@ | ||
// 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.setbigint64 | ||
description: > | ||
Return abrupt from ToBigInt(value) | ||
features: [DataView, ArrayBuffer, BigInt] | ||
---*/ | ||
|
||
var buffer = new ArrayBuffer(8); | ||
var sample = new DataView(buffer, 0); | ||
|
||
var bo1 = { valueOf() { throw new Test262Error(); } }; | ||
var bo2 = { toString() { throw new Test262Error(); } }; | ||
|
||
assert.throws(Test262Error, function() { | ||
sample.setBigInt64(0, bo1); | ||
}, "valueOf"); | ||
|
||
assert.throws(Test262Error, function() { | ||
sample.setBigInt64(0, bo2); | ||
}, "toString"); |
18 changes: 18 additions & 0 deletions
18
...built-ins/DataView/prototype/setBigInt64/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,18 @@ | ||
// 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.setbigint64 | ||
description: > | ||
Return abrupt from ToNumber(symbol byteOffset) | ||
features: [DataView, ArrayBuffer, Symbol, BigInt] | ||
---*/ | ||
|
||
var buffer = new ArrayBuffer(1); | ||
var sample = new DataView(buffer, 0); | ||
|
||
var s = Symbol("1"); | ||
|
||
assert.throws(TypeError, function() { | ||
sample.setBigInt64(s, 1n); | ||
}); |
23 changes: 23 additions & 0 deletions
23
test/built-ins/DataView/prototype/setBigInt64/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,23 @@ | ||
// 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.setbigint64 | ||
description: > | ||
Return abrupt from ToNumber(byteOffset) | ||
features: [DataView, ArrayBuffer, BigInt] | ||
---*/ | ||
|
||
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, function() { | ||
sample.setBigInt64(bo1, 1n); | ||
}, "valueOf"); | ||
|
||
assert.throws(Test262Error, function() { | ||
sample.setBigInt64(bo2, 1n); | ||
}, "toString"); |
Oops, something went wrong.