mirror of
https://github.com/tc39/test262.git
synced 2025-04-08 19:35:28 +02:00
Coverage: Number.prototype.toPrecision throws a RangeError if precision cannot be coerced to a number in range. Fixes gh-2765
This commit is contained in:
parent
f99bec89b7
commit
58559ddddd
28
test/built-ins/Number/prototype/toPrecision/precision-cannot-be-coerced-to-a-number-in-range.js
vendored
Normal file
28
test/built-ins/Number/prototype/toPrecision/precision-cannot-be-coerced-to-a-number-in-range.js
vendored
Normal file
@ -0,0 +1,28 @@
|
||||
// Copyright (C) 2020 Rick Waldron. All rights reserved.
|
||||
// This code is governed by the BSD license found in the LICENSE file.
|
||||
|
||||
/*---
|
||||
esid: sec-number.prototype.toprecision
|
||||
description: >
|
||||
Throws a RangeError if precision cannot be coerced to a number in range.
|
||||
info: |
|
||||
Let p be ? ToInteger(precision).
|
||||
If x is not finite, return ! Number::toString(x).
|
||||
If p < 1 or p > 100, throw a RangeError exception.
|
||||
|
||||
features: [Symbol]
|
||||
---*/
|
||||
|
||||
var toPrecision = Number.prototype.toPrecision;
|
||||
|
||||
assert.throws(RangeError, function() {
|
||||
toPrecision.call(1, function() {});
|
||||
}, "`function() {}` doesn't coerce into a number in range (1-100)");
|
||||
|
||||
assert.throws(RangeError, function() {
|
||||
toPrecision.call(1, NaN);
|
||||
}, "NaN doesn't coerce into a number in range (1-100)");
|
||||
|
||||
assert.throws(RangeError, function() {
|
||||
toPrecision.call(1, {});
|
||||
}, "{} doesn't coerce into a number in range (1-100)");
|
Loading…
x
Reference in New Issue
Block a user