-
Notifications
You must be signed in to change notification settings - Fork 444
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Test Array.prototype.sort called with a primitive
- Loading branch information
1 parent
c8daa32
commit c00087e
Showing
1 changed file
with
30 additions
and
0 deletions.
There are no files selected for viewing
30 changes: 30 additions & 0 deletions
30
test/built-ins/Array/prototype/sort/call-with-primitive.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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"); |