Debian Codegraph @

tests/auto/qml/ecmascripttests/test262/test/built-ins/BigInt/asUintN/bits-toindex-wrapped-values.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.toPrimitive, computed-property-names]
11 ---*/
12
13 assert.sameValue(BigInt.asUintN(Object(0), 1n), 0n, "ToPrimitive: unbox object with internal slot");
14 assert.sameValue(BigInt.asUintN({
15 [Symbol.toPrimitive]: function() {
16 return 0;
17 }
18 }, 1n), 0n, "ToPrimitive: @@toPrimitive");
19 assert.sameValue(BigInt.asUintN({
20 valueOf: function() {
21 return 0;
22 }
23 }, 1n), 0n, "ToPrimitive: valueOf");
24 assert.sameValue(BigInt.asUintN({
25 toString: function() {
26 return 0;
27 }
28 }, 1n), 0n, "ToPrimitive: toString");
29 assert.sameValue(BigInt.asUintN(Object(NaN), 1n), 0n,
30 "ToIndex: unbox object with internal slot => NaN => 0");
31 assert.sameValue(BigInt.asUintN({
32 [Symbol.toPrimitive]: function() {
33 return NaN;
34 }
35 }, 1n), 0n, "ToIndex: @@toPrimitive => NaN => 0");
36 assert.sameValue(BigInt.asUintN({
37 valueOf: function() {
38 return NaN;
39 }
40 }, 1n), 0n, "ToIndex: valueOf => NaN => 0");
41 assert.sameValue(BigInt.asUintN({
42 toString: function() {
43 return NaN;
44 }
45 }, 1n), 0n, "ToIndex: toString => NaN => 0");
46 assert.sameValue(BigInt.asUintN({
47 [Symbol.toPrimitive]: function() {
48 return undefined;
49 }
50 }, 1n), 0n, "ToIndex: @@toPrimitive => undefined => NaN => 0");
51 assert.sameValue(BigInt.asUintN({
52 valueOf: function() {
53 return undefined;
54 }
55 }, 1n), 0n, "ToIndex: valueOf => undefined => NaN => 0");
56 assert.sameValue(BigInt.asUintN({
57 toString: function() {
58 return undefined;
59 }
60 }, 1n), 0n, "ToIndex: toString => undefined => NaN => 0");
61 assert.sameValue(BigInt.asUintN({
62 [Symbol.toPrimitive]: function() {
63 return null;
64 }
65 }, 1n), 0n, "ToIndex: @@toPrimitive => null => 0");
66 assert.sameValue(BigInt.asUintN({
67 valueOf: function() {
68 return null;
69 }
70 }, 1n), 0n, "ToIndex: valueOf => null => 0");
71 assert.sameValue(BigInt.asUintN({
72 toString: function() {
73 return null;
74 }
75 }, 1n), 0n, "ToIndex: toString => null => 0");
76 assert.sameValue(BigInt.asUintN(Object(true), 1n), 1n,
77 "ToIndex: unbox object with internal slot => true => 1");
78 assert.sameValue(BigInt.asUintN({
79 [Symbol.toPrimitive]: function() {
80 return true;
81 }
82 }, 1n), 1n, "ToIndex: @@toPrimitive => true => 1");
83 assert.sameValue(BigInt.asUintN({
84 valueOf: function() {
85 return true;
86 }
87 }, 1n), 1n, "ToIndex: valueOf => true => 1");
88 assert.sameValue(BigInt.asUintN({
89 toString: function() {
90 return true;
91 }
92 }, 1n), 1n, "ToIndex: toString => true => 1");
93 assert.sameValue(BigInt.asUintN(Object("1"), 1n), 1n,
94 "ToIndex: unbox object with internal slot => parse Number");
95 assert.sameValue(BigInt.asUintN({
96 [Symbol.toPrimitive]: function() {
97 return "1";
98 }
99 }, 1n), 1n, "ToIndex: @@toPrimitive => parse Number");
100 assert.sameValue(BigInt.asUintN({
101 valueOf: function() {
102 return "1";
103 }
104 }, 1n), 1n, "ToIndex: valueOf => parse Number");
105 assert.sameValue(BigInt.asUintN({
106 toString: function() {
107 return "1";
108 }
109 }, 1n), 1n, "ToIndex: toString => parse Number");