Backed out 3 changesets (bug 1892041) for causing failures on async-module-does-not...
[gecko.git] / js / src / tests / test262 / built-ins / Number / prototype / toPrecision / undefined-precision-arg.js
blob54ebcc14e49cc756c36369c7305d2dae719a6412
1 // Copyright (C) 2016 The V8 Project authors. All rights reserved.
2 // This code is governed by the BSD license found in the LICENSE file.
4 /*---
5 esid: sec-number.prototype.toprecision
6 description: >
7   Return a string containing the the number value of this if precision is
8   undefined
9 info: |
10   20.1.3 Properties of the Number Prototype Object
12   The Number prototype object is the intrinsic object %NumberPrototype%. The
13   Number prototype object is an ordinary object. The Number prototype is itself
14   a Number object; it has a [[NumberData]] internal slot with the value +0.
16   [...]
17   The abstract operation thisNumberValue(value) performs the following steps:
19   1. If Type(value) is Number, return value.
20   2. If Type(value) is Object and value has a [[NumberData]] internal slot, then
21     a. Assert: value's [[NumberData]] internal slot is a Number value.
22     b. Return the value of value's [[NumberData]] internal slot.
23   3. Throw a TypeError exception.
25   Number.prototype.toPrecision ( precision )
27   1. Let x be ? thisNumberValue(this value).
28   2. If precision is undefined, return ! ToString(x).
29   [...]
30 ---*/
32 var n = new Number(7);
34 assert.sameValue(n.toPrecision(undefined), "7");
35 assert.sameValue((39).toPrecision(undefined), "39");
37 assert.sameValue(Number.prototype.toPrecision(), "0");
38 assert.sameValue((42).toPrecision(), "42");
40 reportCompare(0, 0);