diff options
Diffstat (limited to 'js/src/tests/test262/built-ins/Array/prototype/toSorted/this-value-nullish.js')
-rw-r--r-- | js/src/tests/test262/built-ins/Array/prototype/toSorted/this-value-nullish.js | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/js/src/tests/test262/built-ins/Array/prototype/toSorted/this-value-nullish.js b/js/src/tests/test262/built-ins/Array/prototype/toSorted/this-value-nullish.js new file mode 100644 index 0000000000..65690075df --- /dev/null +++ b/js/src/tests/test262/built-ins/Array/prototype/toSorted/this-value-nullish.js @@ -0,0 +1,24 @@ +// Copyright (C) 2021 Igalia, S.L. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-array.prototype.toSorted +description: > + Array.prototype.toSorted throws if the receiver is null or undefined +info: | + Array.prototype.toSorted ( compareFn ) + + 1. Let O be ? ToObject(this value). + ... +features: [change-array-by-copy] +---*/ + +assert.throws(TypeError, () => { + Array.prototype.toSorted.call(null); +}, '`Array.prototype.toSorted.call(null)` throws TypeError'); + +assert.throws(TypeError, () => { + Array.prototype.toSorted.call(undefined); +}, '`Array.prototype.toSorted.call(undefined)` throws TypeError'); + +reportCompare(0, 0); |