mirror of https://github.com/tc39/test262.git
setBigInt64 tests
This commit is contained in:
parent
a456b0a390
commit
2f20235f3e
20
test/built-ins/DataView/prototype/setBigInt64/detached-buffer-after-bigint-value.js
vendored
Normal file
20
test/built-ins/DataView/prototype/setBigInt64/detached-buffer-after-bigint-value.js
vendored
Normal file
|
@ -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
test/built-ins/DataView/prototype/setBigInt64/detached-buffer-after-toindex-byteoffset.js
vendored
Normal file
23
test/built-ins/DataView/prototype/setBigInt64/detached-buffer-after-toindex-byteoffset.js
vendored
Normal file
|
@ -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
test/built-ins/DataView/prototype/setBigInt64/detached-buffer-before-outofrange-byteoffset.js
vendored
Normal file
21
test/built-ins/DataView/prototype/setBigInt64/detached-buffer-before-outofrange-byteoffset.js
vendored
Normal file
|
@ -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");
|
|
@ -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
test/built-ins/DataView/prototype/setBigInt64/index-check-before-value-conversion.js
vendored
Normal file
32
test/built-ins/DataView/prototype/setBigInt64/index-check-before-value-conversion.js
vendored
Normal file
|
@ -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)");
|
|
@ -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");
|
|
@ -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
|
||||
});
|
|
@ -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
|
||||
});
|
|
@ -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");
|
|
@ -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
test/built-ins/DataView/prototype/setBigInt64/range-check-after-value-conversion.js
vendored
Normal file
21
test/built-ins/DataView/prototype/setBigInt64/range-check-after-value-conversion.js
vendored
Normal file
|
@ -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
test/built-ins/DataView/prototype/setBigInt64/return-abrupt-from-tobigint-value-symbol.js
vendored
Normal file
18
test/built-ins/DataView/prototype/setBigInt64/return-abrupt-from-tobigint-value-symbol.js
vendored
Normal file
|
@ -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
test/built-ins/DataView/prototype/setBigInt64/return-abrupt-from-tobigint-value.js
vendored
Normal file
23
test/built-ins/DataView/prototype/setBigInt64/return-abrupt-from-tobigint-value.js
vendored
Normal file
|
@ -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
test/built-ins/DataView/prototype/setBigInt64/return-abrupt-from-tonumber-byteoffset-symbol.js
vendored
Normal file
18
test/built-ins/DataView/prototype/setBigInt64/return-abrupt-from-tonumber-byteoffset-symbol.js
vendored
Normal file
|
@ -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
test/built-ins/DataView/prototype/setBigInt64/return-abrupt-from-tonumber-byteoffset.js
vendored
Normal file
23
test/built-ins/DataView/prototype/setBigInt64/return-abrupt-from-tonumber-byteoffset.js
vendored
Normal file
|
@ -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");
|
38
test/built-ins/DataView/prototype/setBigInt64/set-values-little-endian-order.js
vendored
Normal file
38
test/built-ins/DataView/prototype/setBigInt64/set-values-little-endian-order.js
vendored
Normal file
|
@ -0,0 +1,38 @@
|
|||
// 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 values on the little endian order
|
||||
features: [DataView, ArrayBuffer, BigInt]
|
||||
---*/
|
||||
|
||||
var buffer = new ArrayBuffer(8);
|
||||
var sample = new DataView(buffer, 0);
|
||||
|
||||
var result;
|
||||
|
||||
result = sample.setBigInt64(0, -0x6f80ff08n, true);
|
||||
assert.sameValue(result, undefined, "returns undefined #1");
|
||||
assert.sameValue(sample.getBigInt64(0), -0x7ff806f00000001n);
|
||||
|
||||
result = sample.setBigInt64(0, -0x7ff8070n, true);
|
||||
assert.sameValue(result, undefined, "returns undefined #2");
|
||||
assert.sameValue(sample.getBigInt64(0), -0x6f80ff0700000001n);
|
||||
|
||||
result = sample.setBigInt64(0, 0x6f80ff08n, true);
|
||||
assert.sameValue(result, undefined, "returns undefined #3");
|
||||
assert.sameValue(sample.getBigInt64(0), 0x8ff806f00000000n);
|
||||
|
||||
result = sample.setBigInt64(0, 0x8ff806fn, true);
|
||||
assert.sameValue(result, undefined, "returns undefined #4");
|
||||
assert.sameValue(sample.getBigInt64(0), 0x6f80ff0800000000n);
|
||||
|
||||
result = sample.setBigInt64(0, 0xf8007f90n, true);
|
||||
assert.sameValue(result, undefined, "returns undefined #5");
|
||||
assert.sameValue(sample.getBigInt64(0), -0x6f80ff0800000000n);
|
||||
|
||||
result = sample.setBigInt64(0, 0x907f00f8n, true);
|
||||
assert.sameValue(result, undefined, "returns undefined #6");
|
||||
assert.sameValue(sample.getBigInt64(0), -0x7ff807000000000n);
|
43
test/built-ins/DataView/prototype/setBigInt64/set-values-return-undefined.js
vendored
Normal file
43
test/built-ins/DataView/prototype/setBigInt64/set-values-return-undefined.js
vendored
Normal file
|
@ -0,0 +1,43 @@
|
|||
// 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 values and return undefined
|
||||
includes: [byteConversionValues.js]
|
||||
features: [DataView, ArrayBuffer, BigInt, arrow-function]
|
||||
---*/
|
||||
|
||||
var buffer = new ArrayBuffer(8);
|
||||
var sample = new DataView(buffer, 0);
|
||||
|
||||
var values = byteConversionValues.values;
|
||||
|
||||
values.forEach(function(value, i) {
|
||||
if (value === undefined) {
|
||||
assert.throws(TypeError,
|
||||
() => sample.setBigInt64(0, BigInt(value), false),
|
||||
"value: " + value);
|
||||
return;
|
||||
} else if (!Number.isInteger(value) || value > 9007199254740991) {
|
||||
assert.throws(RangeError,
|
||||
() => sample.setBigInt64(0, BigInt(value), false),
|
||||
"value " + value);
|
||||
return;
|
||||
}
|
||||
|
||||
var result = sample.setBigInt64(0, BigInt(value), false);
|
||||
|
||||
assert.sameValue(
|
||||
sample.getBigInt64(0),
|
||||
BigInt(value),
|
||||
"value: " + value
|
||||
);
|
||||
|
||||
assert.sameValue(
|
||||
result,
|
||||
undefined,
|
||||
"return is undefined, value: " + value
|
||||
);
|
||||
});
|
29
test/built-ins/DataView/prototype/setBigInt64/this-has-no-dataview-internal.js
vendored
Normal file
29
test/built-ins/DataView/prototype/setBigInt64/this-has-no-dataview-internal.js
vendored
Normal file
|
@ -0,0 +1,29 @@
|
|||
// 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 this does not have a [[DataView]] internal slot
|
||||
features: [DataView, ArrayBuffer, BigInt]
|
||||
---*/
|
||||
|
||||
var setBigInt64 = DataView.prototype.setBigInt64;
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
setBigInt64.call({});
|
||||
}, "{}");
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
setBigInt64.call([]);
|
||||
}, "[]");
|
||||
|
||||
var ab = new ArrayBuffer(1);
|
||||
assert.throws(TypeError, function() {
|
||||
setBigInt64.call(ab);
|
||||
}, "ArrayBuffer");
|
||||
|
||||
var ta = new Int8Array();
|
||||
assert.throws(TypeError, function() {
|
||||
setBigInt64.call(ta);
|
||||
}, "TypedArray");
|
|
@ -0,0 +1,39 @@
|
|||
// 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 this is not Object
|
||||
features: [DataView, ArrayBuffer, Symbol, BigInt]
|
||||
---*/
|
||||
|
||||
var setBigInt64 = DataView.prototype.setBigInt64;
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
setBigInt64.call(undefined);
|
||||
}, "undefined");
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
setBigInt64.call(null);
|
||||
}, "null");
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
setBigInt64.call(1);
|
||||
}, "1");
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
setBigInt64.call("string");
|
||||
}, "string");
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
setBigInt64.call(true);
|
||||
}, "true");
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
setBigInt64.call(false);
|
||||
}, "false");
|
||||
|
||||
var s = Symbol("1");
|
||||
assert.throws(TypeError, function() {
|
||||
setBigInt64.call(s);
|
||||
}, "symbol");
|
|
@ -0,0 +1,34 @@
|
|||
// 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: >
|
||||
Boolean littleEndian argument coerced in ToBoolean
|
||||
features: [DataView, ArrayBuffer, Symbol, BigInt]
|
||||
---*/
|
||||
|
||||
var buffer = new ArrayBuffer(8);
|
||||
var sample = new DataView(buffer, 0);
|
||||
|
||||
// False
|
||||
sample.setBigInt64(0, 1n);
|
||||
assert.sameValue(sample.getBigInt64(0), 1n, "no arg");
|
||||
sample.setBigInt64(0, 2n, undefined);
|
||||
assert.sameValue(sample.getBigInt64(0), 2n, "undefined");
|
||||
sample.setBigInt64(0, 3n, null);
|
||||
assert.sameValue(sample.getBigInt64(0), 3n, "null");
|
||||
sample.setBigInt64(0, 4n, 0);
|
||||
assert.sameValue(sample.getBigInt64(0), 4n, "0");
|
||||
sample.setBigInt64(0, 5n, "");
|
||||
assert.sameValue(sample.getBigInt64(0), 5n, "the empty string");
|
||||
|
||||
// True
|
||||
sample.setBigInt64(0, 6n, {});
|
||||
assert.sameValue(sample.getBigInt64(0), 0x600000000000000n, "{}");
|
||||
sample.setBigInt64(0, 7n, Symbol("1"));
|
||||
assert.sameValue(sample.getBigInt64(0), 0x700000000000000n, "symbol");
|
||||
sample.setBigInt64(0, 8n, 1);
|
||||
assert.sameValue(sample.getBigInt64(0), 0x800000000000000n, "1");
|
||||
sample.setBigInt64(0, 9n, "string");
|
||||
assert.sameValue(sample.getBigInt64(0), 0x900000000000000n, "string");
|
|
@ -0,0 +1,83 @@
|
|||
// 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: >
|
||||
ToIndex conversions on byteOffset
|
||||
features: [DataView, ArrayBuffer, BigInt]
|
||||
---*/
|
||||
|
||||
var buffer = new ArrayBuffer(12);
|
||||
var sample = new DataView(buffer, 0);
|
||||
|
||||
var obj1 = { valueOf() { return 3; } };
|
||||
var obj2 = { toString() { return 4; } };
|
||||
|
||||
sample.setBigInt64(0, 0n);
|
||||
sample.setBigInt64(-0, 42n);
|
||||
assert.sameValue(sample.getBigInt64(0), 42n, "-0");
|
||||
|
||||
sample.setBigInt64(3, 0n);
|
||||
sample.setBigInt64(obj1, 42n);
|
||||
assert.sameValue(sample.getBigInt64(3), 42n, "object's valueOf");
|
||||
|
||||
sample.setBigInt64(4, 0n);
|
||||
sample.setBigInt64(obj2, 42n);
|
||||
assert.sameValue(sample.getBigInt64(4), 42n, "object's toString");
|
||||
|
||||
sample.setBigInt64(0, 0n);
|
||||
sample.setBigInt64("", 42n);
|
||||
assert.sameValue(sample.getBigInt64(0), 42n, "the Empty string");
|
||||
|
||||
sample.setBigInt64(0, 0n);
|
||||
sample.setBigInt64("0", 42n);
|
||||
assert.sameValue(sample.getBigInt64(0), 42n, "string '0'");
|
||||
|
||||
sample.setBigInt64(2, 0n);
|
||||
sample.setBigInt64("2", 42n);
|
||||
assert.sameValue(sample.getBigInt64(2), 42n, "string '2'");
|
||||
|
||||
sample.setBigInt64(1, 0n);
|
||||
sample.setBigInt64(true, 42n);
|
||||
assert.sameValue(sample.getBigInt64(1), 42n, "true");
|
||||
|
||||
sample.setBigInt64(0, 0n);
|
||||
sample.setBigInt64(false, 42n);
|
||||
assert.sameValue(sample.getBigInt64(0), 42n, "false");
|
||||
|
||||
sample.setBigInt64(0, 0n);
|
||||
sample.setBigInt64(NaN, 42n);
|
||||
assert.sameValue(sample.getBigInt64(0), 42n, "NaN");
|
||||
|
||||
sample.setBigInt64(0, 0n);
|
||||
sample.setBigInt64(null, 42n);
|
||||
assert.sameValue(sample.getBigInt64(0), 42n, "null");
|
||||
|
||||
sample.setBigInt64(0, 0n);
|
||||
sample.setBigInt64(0.1, 42n);
|
||||
assert.sameValue(sample.getBigInt64(0), 42n, "0.1");
|
||||
|
||||
sample.setBigInt64(0, 0n);
|
||||
sample.setBigInt64(0.9, 42n);
|
||||
assert.sameValue(sample.getBigInt64(0), 42n, "0.9");
|
||||
|
||||
sample.setBigInt64(1, 0n);
|
||||
sample.setBigInt64(1.1, 42n);
|
||||
assert.sameValue(sample.getBigInt64(1), 42n, "1.1");
|
||||
|
||||
sample.setBigInt64(1, 0n);
|
||||
sample.setBigInt64(1.9, 42n);
|
||||
assert.sameValue(sample.getBigInt64(1), 42n, "1.9");
|
||||
|
||||
sample.setBigInt64(0, 0n);
|
||||
sample.setBigInt64(-0.1, 42n);
|
||||
assert.sameValue(sample.getBigInt64(0), 42n, "-0.1");
|
||||
|
||||
sample.setBigInt64(0, 0n);
|
||||
sample.setBigInt64(-0.99999, 42n);
|
||||
assert.sameValue(sample.getBigInt64(0), 42n, "-0.99999");
|
||||
|
||||
sample.setBigInt64(0, 0n);
|
||||
sample.setBigInt64(undefined, 42n);
|
||||
assert.sameValue(sample.getBigInt64(0), 42n, "undefined");
|
Loading…
Reference in New Issue