diff --git a/test/built-ins/TypedArray/prototype/sort/BigInt/sortcompare-with-no-tostring.js b/test/built-ins/TypedArray/prototype/sort/BigInt/sortcompare-with-no-tostring.js index 3f6402c667..f588b36bcc 100644 --- a/test/built-ins/TypedArray/prototype/sort/BigInt/sortcompare-with-no-tostring.js +++ b/test/built-ins/TypedArray/prototype/sort/BigInt/sortcompare-with-no-tostring.js @@ -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])); }); diff --git a/test/built-ins/TypedArray/prototype/sort/sortcompare-with-no-tostring.js b/test/built-ins/TypedArray/prototype/sort/sortcompare-with-no-tostring.js index f3bb0cac03..591c9087b0 100644 --- a/test/built-ins/TypedArray/prototype/sort/sortcompare-with-no-tostring.js +++ b/test/built-ins/TypedArray/prototype/sort/sortcompare-with-no-tostring.js @@ -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"); });