Skip to content
Snippets Groups Projects
Unverified Commit cdbf8185 authored by Leo Balter's avatar Leo Balter Committed by GitHub
Browse files

Merge pull request #1491 from bocoup/bigint-fix

Bigint fix: the remaining bugs found in #1461
parents 2975694f cc866293
No related branches found
No related tags found
No related merge requests found
Showing
with 33 additions and 24 deletions
...@@ -33,6 +33,6 @@ var end = Symbol(1); ...@@ -33,6 +33,6 @@ var end = Symbol(1);
testWithBigIntTypedArrayConstructors(function(TA) { testWithBigIntTypedArrayConstructors(function(TA) {
var sample = new TA(); var sample = new TA();
assert.throws(TypeError, function() { assert.throws(TypeError, function() {
sample.fill(1, 0, end); sample.fill(1n, 0, end);
}); });
}); });
...@@ -32,6 +32,6 @@ var start = Symbol(1); ...@@ -32,6 +32,6 @@ var start = Symbol(1);
testWithBigIntTypedArrayConstructors(function(TA) { testWithBigIntTypedArrayConstructors(function(TA) {
var sample = new TA(); var sample = new TA();
assert.throws(TypeError, function() { assert.throws(TypeError, function() {
sample.fill(1, start); sample.fill(1n, start);
}); });
}); });
...@@ -23,6 +23,6 @@ testWithBigIntTypedArrayConstructors(function(TA) { ...@@ -23,6 +23,6 @@ testWithBigIntTypedArrayConstructors(function(TA) {
var sample = new TA(1); var sample = new TA(1);
$DETACHBUFFER(sample.buffer); $DETACHBUFFER(sample.buffer);
assert.throws(TypeError, function() { assert.throws(TypeError, function() {
sample.includes(0); sample.includes(0n);
}); });
}); });
...@@ -31,6 +31,6 @@ testWithBigIntTypedArrayConstructors(function(TA) { ...@@ -31,6 +31,6 @@ testWithBigIntTypedArrayConstructors(function(TA) {
var sample; var sample;
sample = new TA(42); sample = new TA(42);
assert.sameValue(sample.includes(0, 42), false); assert.sameValue(sample.includes(0n, 42), false);
assert.sameValue(sample.includes(0, 43), false); assert.sameValue(sample.includes(0n, 43), false);
}); });
...@@ -33,7 +33,7 @@ testWithBigIntTypedArrayConstructors(function(TA) { ...@@ -33,7 +33,7 @@ testWithBigIntTypedArrayConstructors(function(TA) {
assert.sameValue(sample.includes(0), false, "returns false"); assert.sameValue(sample.includes(0), false, "returns false");
assert.sameValue(sample.includes(), false, "returns false - no arg"); assert.sameValue(sample.includes(), false, "returns false - no arg");
assert.sameValue( assert.sameValue(
sample.includes(0, fromIndex), false, sample.includes(0n, fromIndex), false,
"length is checked before ToInteger(fromIndex)" "length is checked before ToInteger(fromIndex)"
); );
}); });
...@@ -23,6 +23,6 @@ testWithBigIntTypedArrayConstructors(function(TA) { ...@@ -23,6 +23,6 @@ testWithBigIntTypedArrayConstructors(function(TA) {
var sample = new TA(1); var sample = new TA(1);
$DETACHBUFFER(sample.buffer); $DETACHBUFFER(sample.buffer);
assert.throws(TypeError, function() { assert.throws(TypeError, function() {
sample.indexOf(0); sample.indexOf(0n);
}); });
}); });
...@@ -25,6 +25,6 @@ testWithBigIntTypedArrayConstructors(function(TA) { ...@@ -25,6 +25,6 @@ testWithBigIntTypedArrayConstructors(function(TA) {
var sample; var sample;
sample = new TA(42); sample = new TA(42);
assert.sameValue(sample.indexOf(0, 42), -1); assert.sameValue(sample.indexOf(0n, 42), -1);
assert.sameValue(sample.indexOf(0, 43), -1); assert.sameValue(sample.indexOf(0n, 43), -1);
}); });
...@@ -29,9 +29,9 @@ var fromIndex = { ...@@ -29,9 +29,9 @@ var fromIndex = {
testWithBigIntTypedArrayConstructors(function(TA) { testWithBigIntTypedArrayConstructors(function(TA) {
var sample = new TA(); var sample = new TA();
assert.sameValue(sample.indexOf(0), -1, "returns -1"); assert.sameValue(sample.indexOf(0n), -1, "returns -1");
assert.sameValue( assert.sameValue(
sample.indexOf(0, fromIndex), -1, sample.indexOf(0n, fromIndex), -1,
"length is checked before ToInteger(fromIndex)" "length is checked before ToInteger(fromIndex)"
); );
}); });
...@@ -27,6 +27,6 @@ testWithBigIntTypedArrayConstructors(function(TA) { ...@@ -27,6 +27,6 @@ testWithBigIntTypedArrayConstructors(function(TA) {
var sample = new TA(1); var sample = new TA(1);
assert.throws(TypeError, function() { assert.throws(TypeError, function() {
sample.indexOf(7, fromIndex); sample.indexOf(7n, fromIndex);
}); });
}); });
...@@ -31,6 +31,6 @@ testWithBigIntTypedArrayConstructors(function(TA) { ...@@ -31,6 +31,6 @@ testWithBigIntTypedArrayConstructors(function(TA) {
var sample = new TA(1); var sample = new TA(1);
assert.throws(Test262Error, function() { assert.throws(Test262Error, function() {
sample.indexOf(7, fromIndex); sample.indexOf(7n, fromIndex);
}); });
}); });
...@@ -23,6 +23,6 @@ testWithBigIntTypedArrayConstructors(function(TA) { ...@@ -23,6 +23,6 @@ testWithBigIntTypedArrayConstructors(function(TA) {
var sample = new TA(1); var sample = new TA(1);
$DETACHBUFFER(sample.buffer); $DETACHBUFFER(sample.buffer);
assert.throws(TypeError, function() { assert.throws(TypeError, function() {
sample.lastIndexOf(0); sample.lastIndexOf(0n);
}); });
}); });
...@@ -31,7 +31,7 @@ testWithBigIntTypedArrayConstructors(function(TA) { ...@@ -31,7 +31,7 @@ testWithBigIntTypedArrayConstructors(function(TA) {
var sample = new TA(); var sample = new TA();
assert.sameValue(sample.lastIndexOf(0), -1, "returns -1"); assert.sameValue(sample.lastIndexOf(0), -1, "returns -1");
assert.sameValue( assert.sameValue(
sample.lastIndexOf(0, fromIndex), -1, sample.lastIndexOf(0n, fromIndex), -1,
"length is checked before ToInteger(fromIndex)" "length is checked before ToInteger(fromIndex)"
); );
}); });
...@@ -27,6 +27,6 @@ testWithBigIntTypedArrayConstructors(function(TA) { ...@@ -27,6 +27,6 @@ testWithBigIntTypedArrayConstructors(function(TA) {
var sample = new TA(1); var sample = new TA(1);
assert.throws(TypeError, function() { assert.throws(TypeError, function() {
sample.lastIndexOf(7, fromIndex); sample.lastIndexOf(7n, fromIndex);
}); });
}); });
...@@ -31,6 +31,6 @@ testWithBigIntTypedArrayConstructors(function(TA) { ...@@ -31,6 +31,6 @@ testWithBigIntTypedArrayConstructors(function(TA) {
var sample = new TA(1); var sample = new TA(1);
assert.throws(Test262Error, function() { assert.throws(Test262Error, function() {
sample.lastIndexOf(7, fromIndex); sample.lastIndexOf(7n, fromIndex);
}); });
}); });
...@@ -13,7 +13,8 @@ features: [BigInt, SharedArrayBuffer, TypedArray] ...@@ -13,7 +13,8 @@ features: [BigInt, SharedArrayBuffer, TypedArray]
testWithBigIntTypedArrayConstructors(function(TA) { testWithBigIntTypedArrayConstructors(function(TA) {
var sab = new SharedArrayBuffer(2 * BigInt64Array.BYTES_PER_ELEMENT); 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[0] = 42n;
src[1] = 43n; src[1] = 43n;
var sample, result; var sample, result;
......
...@@ -18,10 +18,14 @@ includes: [testBigIntTypedArray.js, compareArray.js] ...@@ -18,10 +18,14 @@ includes: [testBigIntTypedArray.js, compareArray.js]
features: [BigInt, TypedArray] features: [BigInt, TypedArray]
---*/ ---*/
var origToString = Number.prototype.toString; var toStringCalled = false;
BigInt.prototype.toString = function() {
toStringCalled = true;
}
testWithBigIntTypedArrayConstructors(function(TA) { testWithBigIntTypedArrayConstructors(function(TA) {
var sample = new TA([20n, 100n, 3n]); var sample = new TA([20n, 100n, 3n]);
var result = sample.sort(); var result = sample.sort();
assert.sameValue(toStringCalled, false, "BigInt.prototype.toString will not be called");
assert(compareArray(result, [3n, 20n, 100n])); assert(compareArray(result, [3n, 20n, 100n]));
}); });
...@@ -18,10 +18,14 @@ includes: [testTypedArray.js, compareArray.js] ...@@ -18,10 +18,14 @@ includes: [testTypedArray.js, compareArray.js]
features: [TypedArray] features: [TypedArray]
---*/ ---*/
var origToString = Number.prototype.toString; var toStringCalled = false;
Number.prototype.toString = function() {
toStringCalled = true;
}
testWithTypedArrayConstructors(function(TA) { testWithTypedArrayConstructors(function(TA) {
var sample = new TA([20, 100, 3]); var sample = new TA([20, 100, 3]);
var result = sample.sort(); 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] ...@@ -20,7 +20,7 @@ features: [BigInt, SharedArrayBuffer, TypedArray]
---*/ ---*/
testWithBigIntTypedArrayConstructors(function(TA) { testWithBigIntTypedArrayConstructors(function(TA) {
var buffer = new SharedArrayBuffer(4); var buffer = new SharedArrayBuffer(TA.BYTES_PER_ELEMENT);
assert.throws(TypeError, function() { assert.throws(TypeError, function() {
TA(buffer); TA(buffer);
}); });
......
...@@ -19,7 +19,7 @@ features: [BigInt, TypedArray] ...@@ -19,7 +19,7 @@ features: [BigInt, TypedArray]
---*/ ---*/
testWithBigIntTypedArrayConstructors(function(TA) { testWithBigIntTypedArrayConstructors(function(TA) {
var buffer = new ArrayBuffer(4); var buffer = new ArrayBuffer(TA.BYTES_PER_ELEMENT);
assert.throws(TypeError, function() { assert.throws(TypeError, function() {
TA(buffer); TA(buffer);
}); });
......
...@@ -26,7 +26,7 @@ features: [BigInt, TypedArray] ...@@ -26,7 +26,7 @@ features: [BigInt, TypedArray]
---*/ ---*/
testWithBigIntTypedArrayConstructors(function(TA) { testWithBigIntTypedArrayConstructors(function(TA) {
var OtherCtor = TA === Int8Array ? Int16Array : Int8Array; var OtherCtor = TA === BigInt64Array ? BigUint64Array : BigInt64Array;
var sample = new OtherCtor(); var sample = new OtherCtor();
Object.defineProperty(sample.buffer, "constructor", { Object.defineProperty(sample.buffer, "constructor", {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment