mirror of https://github.com/tc39/test262.git
BigInt: fix test sortcompare does not call toString
This commit is contained in:
parent
2975694f86
commit
fcb5207932
|
@ -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]
|
||||||
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");
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue