BigInt: fix test sortcompare does not call toString

This commit is contained in:
Valerie R Young 2018-03-13 13:26:50 -04:00
parent 2975694f86
commit fcb5207932
2 changed files with 11 additions and 3 deletions

View File

@ -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]));
});

View File

@ -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");
});