summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/built-ins/BigInt/prototype/valueOf/this-value-invalid-object-throws.js
blob: 994587d32502ec01fa4540bc9425c3551d07d942 (plain)
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
// 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 an Object without a [[BigIntData]] internal.
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]
---*/

var valueOf = BigInt.prototype.valueOf;
assert.sameValue(typeof valueOf, 'function');

assert.throws(TypeError, function() {
  valueOf.call({});
}, "{}");

assert.throws(TypeError, function() {
  valueOf.call(Object(1));
}, "Object(1)");

reportCompare(0, 0);