Debian Codegraph @

tests/auto/qml/ecmascripttests/test262/test/built-ins/BigInt/asUintN/bits-toindex-errors.js

raw
1 // Copyright (C) 2017 Josh Wolfe. All rights reserved.
2 // This code is governed by the BSD license found in the LICENSE file.
3 /*---
4 description: BigInt.asUintN type coercion for bits parameter
5 esid: pending
6 info: |
7 BigInt.asUintN ( bits, bigint )
8
9 1. Let bits be ? ToIndex(bits).
10 features: [BigInt, Symbol, Symbol.toPrimitive, computed-property-names]
11 ---*/
12
13 assert.throws(RangeError, function() {
14 BigInt.asUintN(-1, 0n);
15 }, "ToIndex: throw when integerIndex < 0");
16 assert.throws(RangeError, function() {
17 BigInt.asUintN(-2.5, 0n);
18 }, "ToIndex: throw when integerIndex < 0");
19 assert.throws(RangeError, function() {
20 BigInt.asUintN("-2.5", 0n);
21 }, "ToIndex: parse Number => throw when integerIndex < 0");
22 assert.throws(RangeError, function() {
23 BigInt.asUintN(-Infinity, 0n);
24 }, "ToIndex: throw when integerIndex < 0");
25 assert.throws(RangeError, function() {
26 BigInt.asUintN(9007199254740992, 0n);
27 }, "ToIndex: throw when integerIndex > 2**53-1");
28 assert.throws(RangeError, function() {
29 BigInt.asUintN(Infinity, 0n);
30 }, "ToIndex: throw when integerIndex > 2**53-1");
31 assert.throws(TypeError, function() {
32 BigInt.asUintN(0n, 0n);
33 }, "ToIndex: BigInt => TypeError");
34 assert.throws(TypeError, function() {
35 BigInt.asUintN(Object(0n), 0n);
36 }, "ToIndex: unbox object with internal slot => BigInt => TypeError");
37 assert.throws(TypeError, function() {
38 BigInt.asUintN({
39 [Symbol.toPrimitive]: function() {
40 return 0n;
41 }
42 }, 0n);
43 }, "ToIndex: @@toPrimitive => BigInt => TypeError");
44 assert.throws(TypeError, function() {
45 BigInt.asUintN({
46 valueOf: function() {
47 return 0n;
48 }
49 }, 0n);
50 }, "ToIndex: valueOf => BigInt => TypeError");
51 assert.throws(TypeError, function() {
52 BigInt.asUintN({
53 toString: function() {
54 return 0n;
55 }
56 }, 0n);
57 }, "ToIndex: toString => BigInt => TypeError");
58 assert.throws(TypeError, function() {
59 BigInt.asUintN(Symbol("1"), 0n);
60 }, "ToIndex: Symbol => TypeError");
61 assert.throws(TypeError, function() {
62 BigInt.asUintN(Object(Symbol("1")), 0n);
63 }, "ToIndex: unbox object with internal slot => Symbol => TypeError");
64 assert.throws(TypeError, function() {
65 BigInt.asUintN({
66 [Symbol.toPrimitive]: function() {
67 return Symbol("1");
68 }
69 }, 0n);
70 }, "ToIndex: @@toPrimitive => Symbol => TypeError");
71 assert.throws(TypeError, function() {
72 BigInt.asUintN({
73 valueOf: function() {
74 return Symbol("1");
75 }
76 }, 0n);
77 }, "ToIndex: valueOf => Symbol => TypeError");
78 assert.throws(TypeError, function() {
79 BigInt.asUintN({
80 toString: function() {
81 return Symbol("1");
82 }
83 }, 0n);
84 }, "ToIndex: toString => Symbol => TypeError");