mirror of
https://github.com/tc39/test262.git
synced 2025-07-29 17:04:31 +02:00
Test Array.prototype.sort called with a primitive
This commit is contained in:
parent
c8daa32e48
commit
c00087e129
30
test/built-ins/Array/prototype/sort/call-with-primitive.js
vendored
Normal file
30
test/built-ins/Array/prototype/sort/call-with-primitive.js
vendored
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
// Copyright (C) 2021 Alexey Shvayka. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
|
||||||
|
/*---
|
||||||
|
esid: sec-array.prototype.sort
|
||||||
|
description: >
|
||||||
|
This value is coerced to an object.
|
||||||
|
info: |
|
||||||
|
Array.prototype.sort ( comparefn )
|
||||||
|
|
||||||
|
[...]
|
||||||
|
2. Let obj be ? ToObject(this value).
|
||||||
|
[...]
|
||||||
|
12. Return obj.
|
||||||
|
features: [Symbol, BigInt]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
assert.throws(TypeError, function() {
|
||||||
|
[].sort.call(undefined);
|
||||||
|
}, "undefined");
|
||||||
|
|
||||||
|
assert.throws(TypeError, function() {
|
||||||
|
[].sort.call(null);
|
||||||
|
}, "null");
|
||||||
|
|
||||||
|
assert([].sort.call(false) instanceof Boolean, "boolean");
|
||||||
|
assert([].sort.call(0) instanceof Number, "number");
|
||||||
|
assert([].sort.call("") instanceof String, "string");
|
||||||
|
assert([].sort.call(Symbol()) instanceof Symbol, "symbol");
|
||||||
|
assert([].sort.call(0n) instanceof BigInt, "bigint");
|
Loading…
x
Reference in New Issue
Block a user