1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
// 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.valueof
description: >
Throws a TypeError if this is not a BigInt neither an Object.
info: |
BigInt.prototype.valueOf ( )
1. Return ? thisBigIntValue(this value).
The abstract operation thisBigIntValue(value) performs the following steps:
1. If Type(value) is BigInt, return value.
2. If Type(value) is Object and value has a [[BigIntData]] internal slot, then
...
3. Throw a TypeError exception.
features: [BigInt, Symbol]
---*/
var valueOf = BigInt.prototype.valueOf;
assert.sameValue(typeof valueOf, 'function');
assert.throws(TypeError, function() {
valueOf.call(undefined);
}, "undefined");
assert.throws(TypeError, function() {
valueOf.call(null);
}, "null");
assert.throws(TypeError, function() {
valueOf.call(false);
}, "false");
assert.throws(TypeError, function() {
valueOf.call(true);
}, "true");
assert.throws(TypeError, function() {
valueOf.call("");
}, "the empty string");
assert.throws(TypeError, function() {
valueOf.call("1n");
}, "string");
assert.throws(TypeError, function() {
valueOf.call(0);
}, "number (0)");
assert.throws(TypeError, function() {
valueOf.call(1);
}, "number (1)");
assert.throws(TypeError, function() {
valueOf.call(NaN);
}, "NaN");
var s = Symbol();
assert.throws(TypeError, function() {
valueOf.call(s);
}, "symbol");
reportCompare(0, 0);
|