mirror of
https://github.com/tc39/test262.git
synced 2025-07-28 16:34:27 +02:00
BigInt.prototype.toString
This commit is contained in:
parent
1afb7c74fd
commit
8ca8f06ba1
19
test/built-ins/BigInt/prototype/toString/length.js
vendored
Normal file
19
test/built-ins/BigInt/prototype/toString/length.js
vendored
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
// Copyright (C) 2017 Robin Templeton. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
|
||||||
|
/*---
|
||||||
|
esid: sec-bigint.prototype.tostring
|
||||||
|
description: BigInt.prototype.toString.length property descriptor
|
||||||
|
info: >
|
||||||
|
BigInt.prototype.toString ( [ radix ] )
|
||||||
|
|
||||||
|
17 ECMAScript Standard Built-in Objects
|
||||||
|
includes: [propertyHelper.js]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
verifyProperty(BigInt.prototype.toString, "length", {
|
||||||
|
value: 1,
|
||||||
|
writable: false,
|
||||||
|
enumerable: false,
|
||||||
|
configurable: true
|
||||||
|
});
|
19
test/built-ins/BigInt/prototype/toString/name.js
vendored
Normal file
19
test/built-ins/BigInt/prototype/toString/name.js
vendored
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
// Copyright (C) 2017 Robin Templeton. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
|
||||||
|
/*---
|
||||||
|
esid: sec-bigint.prototype.tostring
|
||||||
|
description: BigInt.prototype.toString.name property descriptor
|
||||||
|
info: >
|
||||||
|
BigInt.prototype.toString ( [ radix ] )
|
||||||
|
|
||||||
|
17 ECMAScript Standard Built-in Objects
|
||||||
|
includes: [propertyHelper.js]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
verifyProperty(BigInt.prototype.toString, "name", {
|
||||||
|
value: "toString",
|
||||||
|
writable: false,
|
||||||
|
enumerable: false,
|
||||||
|
configurable: true
|
||||||
|
});
|
16
test/built-ins/BigInt/prototype/toString/non-bigint.js
vendored
Normal file
16
test/built-ins/BigInt/prototype/toString/non-bigint.js
vendored
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
// Copyright 2017 Robin Templeton. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
|
||||||
|
/*---
|
||||||
|
esid: sec-bigint.prototype.tostring
|
||||||
|
description: Transferring toString to non-BigInt objects
|
||||||
|
info: >
|
||||||
|
BigInt.prototype.toString ( [ radix ] )
|
||||||
|
|
||||||
|
1. Let x be ? thisBigIntValue(this value).
|
||||||
|
---*/
|
||||||
|
|
||||||
|
for (let x of [new String(), new Boolean(), new Date(), new Object(), {x: 1}]) {
|
||||||
|
x.toString = Number.prototype.toString;
|
||||||
|
assert.throws(TypeError, () => x.toString());
|
||||||
|
}
|
18
test/built-ins/BigInt/prototype/toString/prop-desc.js
vendored
Normal file
18
test/built-ins/BigInt/prototype/toString/prop-desc.js
vendored
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
// Copyright (C) 2016 Robin Templeton. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
|
||||||
|
/*---
|
||||||
|
esid: sec-bigint.prototype.tostring
|
||||||
|
description: BigInt.prototype.toString property descriptor
|
||||||
|
info: >
|
||||||
|
BigInt.prototype.toString ( [ radix ] )
|
||||||
|
|
||||||
|
17 ECMAScript Standard Built-in Objects
|
||||||
|
includes: [propertyHelper.js]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
verifyProperty(BigInt.prototype, "toString", {
|
||||||
|
writable: true,
|
||||||
|
enumerable: false,
|
||||||
|
configurable: true
|
||||||
|
});
|
20
test/built-ins/BigInt/prototype/toString/prototype-call.js
vendored
Normal file
20
test/built-ins/BigInt/prototype/toString/prototype-call.js
vendored
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
// Copyright 2017 Robin Templeton. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
|
||||||
|
/*---
|
||||||
|
esid: sec-bigint.prototype.tostring
|
||||||
|
description: Direct toString on BigInt prototype
|
||||||
|
info: >
|
||||||
|
BigInt.prototype.toString ( [ radix ] )
|
||||||
|
|
||||||
|
Let x be ? thisBigIntValue(this value).
|
||||||
|
|
||||||
|
Properties of the BigInt Prototype Object
|
||||||
|
|
||||||
|
The BigInt prototype is not a BigInt object; it does not have a
|
||||||
|
[[BigIntData]] internal slot.
|
||||||
|
---*/
|
||||||
|
|
||||||
|
assert.throws(TypeError, () => BigInt.prototype.toString());
|
||||||
|
assert.throws(TypeError, () => BigInt.prototype.toString(10));
|
||||||
|
assert.throws(TypeError, () => BigInt.prototype.toString(undefined));
|
24
test/built-ins/BigInt/prototype/toString/radix-2-to-36.js
vendored
Normal file
24
test/built-ins/BigInt/prototype/toString/radix-2-to-36.js
vendored
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
// Copyright 2017 Robin Templeton. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
|
||||||
|
/*---
|
||||||
|
esid: sec-bigint.prototype.tostring
|
||||||
|
description: toString with radix between 2 and 36
|
||||||
|
info: >
|
||||||
|
BigInt.prototype.toString ( [ radix ] )
|
||||||
|
|
||||||
|
[...]
|
||||||
|
6. If radixNumber = 10, return ! ToString(x).
|
||||||
|
7. Return the String representation of this Number value using the
|
||||||
|
radix specified by radixNumber. Letters a-z are used for digits
|
||||||
|
with values 10 through 35. The precise algorithm is
|
||||||
|
implementation-dependent, however the algorithm should be a
|
||||||
|
generalization of that specified in 3.1.4.1.
|
||||||
|
---*/
|
||||||
|
|
||||||
|
for (let r = 2; r <= 36; r++) {
|
||||||
|
assert.throws(TypeError, () => BigInt.prototype.toString(r));
|
||||||
|
assert.sameValue((0n).toString(r), "0", "0, radix " + r);
|
||||||
|
assert.sameValue((-1n).toString(r), "-1", "-1, radix " + r);
|
||||||
|
assert.sameValue((1n).toString(r), "1", "1, radix " + r);
|
||||||
|
}
|
21
test/built-ins/BigInt/prototype/toString/radix-err.js
vendored
Normal file
21
test/built-ins/BigInt/prototype/toString/radix-err.js
vendored
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
// Copyright 2017 Robin Templeton. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
|
||||||
|
/*---
|
||||||
|
esid: sec-bigint.prototype.tostring
|
||||||
|
description: toString with invalid radix
|
||||||
|
info: >
|
||||||
|
BigInt.prototype.toString ( [ radix ] )
|
||||||
|
|
||||||
|
[...]
|
||||||
|
4. Else, let radixNumber be ? ToInteger(radix).
|
||||||
|
5. If radixNumber < 2 or radixNumber > 36, throw a RangeError
|
||||||
|
exception.
|
||||||
|
---*/
|
||||||
|
|
||||||
|
for (let r of [0, 1, 37, null]) {
|
||||||
|
assert.throws(TypeError, () => BigInt.prototype.toString(r));
|
||||||
|
assert.throws(RangeError, () => (0n).toString(r), "0, radix " + r);
|
||||||
|
assert.throws(RangeError, () => (-1n).toString(r), "-1, radix " + r);
|
||||||
|
assert.throws(RangeError, () => (1n).toString(r), "1, radix " + r);
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user