mirror of
https://github.com/tc39/test262.git
synced 2025-07-28 16:34:27 +02:00
Merge pull request #1491 from bocoup/bigint-fix
Bigint fix: the remaining bugs found in #1461
This commit is contained in:
commit
cdbf81856b
@ -33,6 +33,6 @@ var end = Symbol(1);
|
||||
testWithBigIntTypedArrayConstructors(function(TA) {
|
||||
var sample = new TA();
|
||||
assert.throws(TypeError, function() {
|
||||
sample.fill(1, 0, end);
|
||||
sample.fill(1n, 0, end);
|
||||
});
|
||||
});
|
||||
|
@ -32,6 +32,6 @@ var start = Symbol(1);
|
||||
testWithBigIntTypedArrayConstructors(function(TA) {
|
||||
var sample = new TA();
|
||||
assert.throws(TypeError, function() {
|
||||
sample.fill(1, start);
|
||||
sample.fill(1n, start);
|
||||
});
|
||||
});
|
||||
|
@ -23,6 +23,6 @@ testWithBigIntTypedArrayConstructors(function(TA) {
|
||||
var sample = new TA(1);
|
||||
$DETACHBUFFER(sample.buffer);
|
||||
assert.throws(TypeError, function() {
|
||||
sample.includes(0);
|
||||
sample.includes(0n);
|
||||
});
|
||||
});
|
||||
|
@ -31,6 +31,6 @@ testWithBigIntTypedArrayConstructors(function(TA) {
|
||||
var sample;
|
||||
|
||||
sample = new TA(42);
|
||||
assert.sameValue(sample.includes(0, 42), false);
|
||||
assert.sameValue(sample.includes(0, 43), false);
|
||||
assert.sameValue(sample.includes(0n, 42), false);
|
||||
assert.sameValue(sample.includes(0n, 43), false);
|
||||
});
|
||||
|
@ -33,7 +33,7 @@ testWithBigIntTypedArrayConstructors(function(TA) {
|
||||
assert.sameValue(sample.includes(0), false, "returns false");
|
||||
assert.sameValue(sample.includes(), false, "returns false - no arg");
|
||||
assert.sameValue(
|
||||
sample.includes(0, fromIndex), false,
|
||||
sample.includes(0n, fromIndex), false,
|
||||
"length is checked before ToInteger(fromIndex)"
|
||||
);
|
||||
});
|
||||
|
@ -23,6 +23,6 @@ testWithBigIntTypedArrayConstructors(function(TA) {
|
||||
var sample = new TA(1);
|
||||
$DETACHBUFFER(sample.buffer);
|
||||
assert.throws(TypeError, function() {
|
||||
sample.indexOf(0);
|
||||
sample.indexOf(0n);
|
||||
});
|
||||
});
|
||||
|
@ -25,6 +25,6 @@ testWithBigIntTypedArrayConstructors(function(TA) {
|
||||
var sample;
|
||||
|
||||
sample = new TA(42);
|
||||
assert.sameValue(sample.indexOf(0, 42), -1);
|
||||
assert.sameValue(sample.indexOf(0, 43), -1);
|
||||
assert.sameValue(sample.indexOf(0n, 42), -1);
|
||||
assert.sameValue(sample.indexOf(0n, 43), -1);
|
||||
});
|
||||
|
@ -29,9 +29,9 @@ var fromIndex = {
|
||||
|
||||
testWithBigIntTypedArrayConstructors(function(TA) {
|
||||
var sample = new TA();
|
||||
assert.sameValue(sample.indexOf(0), -1, "returns -1");
|
||||
assert.sameValue(sample.indexOf(0n), -1, "returns -1");
|
||||
assert.sameValue(
|
||||
sample.indexOf(0, fromIndex), -1,
|
||||
sample.indexOf(0n, fromIndex), -1,
|
||||
"length is checked before ToInteger(fromIndex)"
|
||||
);
|
||||
});
|
||||
|
@ -27,6 +27,6 @@ testWithBigIntTypedArrayConstructors(function(TA) {
|
||||
var sample = new TA(1);
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
sample.indexOf(7, fromIndex);
|
||||
sample.indexOf(7n, fromIndex);
|
||||
});
|
||||
});
|
||||
|
@ -31,6 +31,6 @@ testWithBigIntTypedArrayConstructors(function(TA) {
|
||||
var sample = new TA(1);
|
||||
|
||||
assert.throws(Test262Error, function() {
|
||||
sample.indexOf(7, fromIndex);
|
||||
sample.indexOf(7n, fromIndex);
|
||||
});
|
||||
});
|
||||
|
@ -23,6 +23,6 @@ testWithBigIntTypedArrayConstructors(function(TA) {
|
||||
var sample = new TA(1);
|
||||
$DETACHBUFFER(sample.buffer);
|
||||
assert.throws(TypeError, function() {
|
||||
sample.lastIndexOf(0);
|
||||
sample.lastIndexOf(0n);
|
||||
});
|
||||
});
|
||||
|
@ -31,7 +31,7 @@ testWithBigIntTypedArrayConstructors(function(TA) {
|
||||
var sample = new TA();
|
||||
assert.sameValue(sample.lastIndexOf(0), -1, "returns -1");
|
||||
assert.sameValue(
|
||||
sample.lastIndexOf(0, fromIndex), -1,
|
||||
sample.lastIndexOf(0n, fromIndex), -1,
|
||||
"length is checked before ToInteger(fromIndex)"
|
||||
);
|
||||
});
|
||||
|
@ -27,6 +27,6 @@ testWithBigIntTypedArrayConstructors(function(TA) {
|
||||
var sample = new TA(1);
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
sample.lastIndexOf(7, fromIndex);
|
||||
sample.lastIndexOf(7n, fromIndex);
|
||||
});
|
||||
});
|
||||
|
@ -31,6 +31,6 @@ testWithBigIntTypedArrayConstructors(function(TA) {
|
||||
var sample = new TA(1);
|
||||
|
||||
assert.throws(Test262Error, function() {
|
||||
sample.lastIndexOf(7, fromIndex);
|
||||
sample.lastIndexOf(7n, fromIndex);
|
||||
});
|
||||
});
|
||||
|
@ -13,7 +13,8 @@ features: [BigInt, SharedArrayBuffer, TypedArray]
|
||||
|
||||
testWithBigIntTypedArrayConstructors(function(TA) {
|
||||
var sab = new SharedArrayBuffer(2 * BigInt64Array.BYTES_PER_ELEMENT);
|
||||
var src = new BigInt64Array(sab);
|
||||
var otherCtor = TA === BigInt64Array ? BigUint64Array : BigInt64Array;
|
||||
var src = new otherCtor(sab);
|
||||
src[0] = 42n;
|
||||
src[1] = 43n;
|
||||
var sample, result;
|
||||
|
@ -18,10 +18,14 @@ includes: [testBigIntTypedArray.js, compareArray.js]
|
||||
features: [BigInt, TypedArray]
|
||||
---*/
|
||||
|
||||
var origToString = Number.prototype.toString;
|
||||
var toStringCalled = false;
|
||||
BigInt.prototype.toString = function() {
|
||||
toStringCalled = true;
|
||||
}
|
||||
|
||||
testWithBigIntTypedArrayConstructors(function(TA) {
|
||||
var sample = new TA([20n, 100n, 3n]);
|
||||
var result = sample.sort();
|
||||
assert.sameValue(toStringCalled, false, "BigInt.prototype.toString will not be called");
|
||||
assert(compareArray(result, [3n, 20n, 100n]));
|
||||
});
|
||||
|
@ -18,10 +18,14 @@ includes: [testTypedArray.js, compareArray.js]
|
||||
features: [TypedArray]
|
||||
---*/
|
||||
|
||||
var origToString = Number.prototype.toString;
|
||||
var toStringCalled = false;
|
||||
Number.prototype.toString = function() {
|
||||
toStringCalled = true;
|
||||
}
|
||||
|
||||
testWithTypedArrayConstructors(function(TA) {
|
||||
var sample = new TA([20, 100, 3]);
|
||||
var result = sample.sort();
|
||||
assert(compareArray(result, [3, 20, 100]));
|
||||
assert.sameValue(toStringCalled, false, "Number.prototype.toString will not be called");
|
||||
assert(compareArray(result, [3, 20, 100]), "Default sorting by value");
|
||||
});
|
||||
|
@ -20,7 +20,7 @@ features: [BigInt, SharedArrayBuffer, TypedArray]
|
||||
---*/
|
||||
|
||||
testWithBigIntTypedArrayConstructors(function(TA) {
|
||||
var buffer = new SharedArrayBuffer(4);
|
||||
var buffer = new SharedArrayBuffer(TA.BYTES_PER_ELEMENT);
|
||||
assert.throws(TypeError, function() {
|
||||
TA(buffer);
|
||||
});
|
||||
|
@ -19,7 +19,7 @@ features: [BigInt, TypedArray]
|
||||
---*/
|
||||
|
||||
testWithBigIntTypedArrayConstructors(function(TA) {
|
||||
var buffer = new ArrayBuffer(4);
|
||||
var buffer = new ArrayBuffer(TA.BYTES_PER_ELEMENT);
|
||||
assert.throws(TypeError, function() {
|
||||
TA(buffer);
|
||||
});
|
||||
|
@ -26,7 +26,7 @@ features: [BigInt, TypedArray]
|
||||
---*/
|
||||
|
||||
testWithBigIntTypedArrayConstructors(function(TA) {
|
||||
var OtherCtor = TA === Int8Array ? Int16Array : Int8Array;
|
||||
var OtherCtor = TA === BigInt64Array ? BigUint64Array : BigInt64Array;
|
||||
var sample = new OtherCtor();
|
||||
|
||||
Object.defineProperty(sample.buffer, "constructor", {
|
||||
|
@ -22,7 +22,7 @@ includes: [testBigIntTypedArray.js]
|
||||
features: [BigInt, Symbol.iterator, TypedArray]
|
||||
---*/
|
||||
|
||||
var sourceItor = [1, 2];
|
||||
var sourceItor = [1n, 2n];
|
||||
var sourceObj = {
|
||||
length: 2
|
||||
};
|
||||
|
@ -18,7 +18,7 @@ features: [BigInt, TypedArray]
|
||||
---*/
|
||||
|
||||
var source = {
|
||||
"0": 42,
|
||||
"0": 42n,
|
||||
length: 2
|
||||
};
|
||||
var mapfn = function() {
|
||||
|
@ -29,7 +29,7 @@ features: [BigInt, cross-realm, Reflect, TypedArray]
|
||||
|
||||
var other = $262.createRealm().global;
|
||||
var desc = {
|
||||
value: 0,
|
||||
value: 0n,
|
||||
configurable: false,
|
||||
enumerable: true,
|
||||
writable: true
|
||||
|
@ -27,7 +27,7 @@ features: [BigInt, Reflect, TypedArray]
|
||||
---*/
|
||||
|
||||
var desc = {
|
||||
value: 0,
|
||||
value: 0n,
|
||||
configurable: false,
|
||||
enumerable: true,
|
||||
writable: true
|
||||
|
@ -25,7 +25,7 @@ testWithBigIntTypedArrayConstructors(function(TA) {
|
||||
|
||||
assert.sameValue(
|
||||
Reflect.defineProperty(sample, "2", {
|
||||
value: 42,
|
||||
value: 42n,
|
||||
configurable: false,
|
||||
enumerable: true,
|
||||
writable: true
|
||||
@ -36,7 +36,7 @@ testWithBigIntTypedArrayConstructors(function(TA) {
|
||||
|
||||
assert.sameValue(
|
||||
Reflect.defineProperty(sample, "3", {
|
||||
value: 42,
|
||||
value: 42n,
|
||||
configurable: false,
|
||||
enumerable: true,
|
||||
writable: true
|
||||
|
@ -23,7 +23,7 @@ testWithBigIntTypedArrayConstructors(function(TA) {
|
||||
|
||||
assert.sameValue(
|
||||
Reflect.defineProperty(sample, "-1", {
|
||||
value: 42,
|
||||
value: 42n,
|
||||
configurable: false,
|
||||
enumerable: true,
|
||||
writable: true
|
||||
|
@ -23,7 +23,7 @@ testWithBigIntTypedArrayConstructors(function(TA) {
|
||||
|
||||
assert.sameValue(
|
||||
Reflect.defineProperty(sample, "-0", {
|
||||
value: 42,
|
||||
value: 42n,
|
||||
configurable: false,
|
||||
enumerable: true,
|
||||
writable: true
|
||||
|
@ -21,7 +21,7 @@ testWithBigIntTypedArrayConstructors(function(TA) {
|
||||
|
||||
assert.sameValue(
|
||||
Reflect.defineProperty(sample, "0.1", {
|
||||
value: 42,
|
||||
value: 42n,
|
||||
configurable: false,
|
||||
enumerable: true,
|
||||
writable: true
|
||||
@ -38,7 +38,7 @@ testWithBigIntTypedArrayConstructors(function(TA) {
|
||||
|
||||
assert.sameValue(
|
||||
Reflect.defineProperty(sample, "0.000001", {
|
||||
value: 42,
|
||||
value: 42n,
|
||||
configurable: false,
|
||||
enumerable: true,
|
||||
writable: true
|
||||
@ -58,7 +58,7 @@ testWithBigIntTypedArrayConstructors(function(TA) {
|
||||
|
||||
assert.sameValue(
|
||||
Reflect.defineProperty(sample, "1.1", {
|
||||
value: 42,
|
||||
value: 42n,
|
||||
configurable: false,
|
||||
enumerable: true,
|
||||
writable: true
|
||||
@ -75,7 +75,7 @@ testWithBigIntTypedArrayConstructors(function(TA) {
|
||||
|
||||
assert.sameValue(
|
||||
Reflect.defineProperty(sample, "Infinity", {
|
||||
value: 42,
|
||||
value: 42n,
|
||||
configurable: false,
|
||||
enumerable: true,
|
||||
writable: true
|
||||
@ -99,7 +99,7 @@ testWithBigIntTypedArrayConstructors(function(TA) {
|
||||
|
||||
assert.sameValue(
|
||||
Reflect.defineProperty(sample, "-Infinity", {
|
||||
value: 42,
|
||||
value: 42n,
|
||||
configurable: false,
|
||||
enumerable: true,
|
||||
writable: true
|
||||
|
@ -23,7 +23,7 @@ testWithBigIntTypedArrayConstructors(function(TA) {
|
||||
|
||||
assert.sameValue(
|
||||
Reflect.defineProperty(sample, "0", {
|
||||
value: 42,
|
||||
value: 42n,
|
||||
configurable: true,
|
||||
enumerable: true,
|
||||
writable: true
|
||||
|
@ -23,7 +23,7 @@ testWithBigIntTypedArrayConstructors(function(TA) {
|
||||
|
||||
assert.sameValue(
|
||||
Reflect.defineProperty(sample, "0", {
|
||||
value: 42,
|
||||
value: 42n,
|
||||
configurable: false,
|
||||
enumerable: false,
|
||||
writable: true
|
||||
|
@ -23,7 +23,7 @@ testWithBigIntTypedArrayConstructors(function(TA) {
|
||||
|
||||
assert.sameValue(
|
||||
Reflect.defineProperty(sample, "0", {
|
||||
value: 42,
|
||||
value: 42n,
|
||||
configurable: false,
|
||||
enumerable: true,
|
||||
writable: false
|
||||
|
@ -35,6 +35,6 @@ testWithBigIntTypedArrayConstructors(function(TA) {
|
||||
$DETACHBUFFER(sample.buffer);
|
||||
|
||||
assert.throws(TypeError, function() {
|
||||
sample[0] = 0;
|
||||
sample[0] = 0n;
|
||||
});
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user