Debian Codegraph @

tests/auto/qml/ecmascripttests/test262/test/language/expressions/unsigned-right-shift/bigint-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: unsigned-right-shift operator ToNumeric with BigInt operands
5 esid: sec-unsigned-right-shift-operator-runtime-semantics-evaluation
6 info: After ToNumeric type coercion, unsigned-right-shift always throws for BigInt operands
7 features: [BigInt, Symbol, Symbol.toPrimitive, computed-property-names]
8 ---*/
9
10 assert.throws(TypeError, function() {
11 Symbol("1") >>> 0n;
12 }, "ToBigInt: Symbol => TypeError");
13 assert.throws(TypeError, function() {
14 0n >>> Symbol("1");
15 }, "ToBigInt: Symbol => TypeError");
16 assert.throws(TypeError, function() {
17 Object(Symbol("1")) >>> 0n;
18 }, "ToBigInt: unbox object with internal slot => Symbol => TypeError");
19 assert.throws(TypeError, function() {
20 0n >>> Object(Symbol("1"));
21 }, "ToBigInt: unbox object with internal slot => Symbol => TypeError");
22 assert.throws(TypeError, function() {
23 ({
24 [Symbol.toPrimitive]: function() {
25 return Symbol("1");
26 }
27 }) >>> 0n;
28 }, "ToBigInt: @@toPrimitive => Symbol => TypeError");
29 assert.throws(TypeError, function() {
30 0n >>> {
31 [Symbol.toPrimitive]: function() {
32 return Symbol("1");
33 }
34 };
35 }, "ToBigInt: @@toPrimitive => Symbol => TypeError");
36 assert.throws(TypeError, function() {
37 ({
38 valueOf: function() {
39 return Symbol("1");
40 }
41 }) >>> 0n;
42 }, "ToBigInt: valueOf => Symbol => TypeError");
43 assert.throws(TypeError, function() {
44 0n >>> {
45 valueOf: function() {
46 return Symbol("1");
47 }
48 };
49 }, "ToBigInt: valueOf => Symbol => TypeError");
50 assert.throws(TypeError, function() {
51 ({
52 toString: function() {
53 return Symbol("1");
54 }
55 }) >>> 0n;
56 }, "ToBigInt: toString => Symbol => TypeError");
57 assert.throws(TypeError, function() {
58 0n >>> {
59 toString: function() {
60 return Symbol("1");
61 }
62 };
63 }, "ToBigInt: toString => Symbol => TypeError");