Debian Codegraph @

js/src/tests/test262/language/expressions/right-shift/bigint-and-number.js

raw
1 // Copyright (C) 2018 Igalia, S.L. All rights reserved.
2 // This code is governed by the BSD license found in the LICENSE file.
3 /*---
4 esid: sec-signed-right-shift-operator-runtime-semantics-evaluation
5 description: Mixing BigInt and Number produces a TypeError for right-shift operator
6 features: [BigInt]
7 info: |
8 Let lnum be ? ToNumeric(leftValue).
9 Let rnum be ? ToNumeric(rightValue).
10 If Type(lnum) does not equal Type(rnum), throw a TypeError exception.
11 ---*/
12 assert.throws(TypeError, function() {
13 1n >> 1;
14 }, '1n >> 1 throws TypeError');
15
16 assert.throws(TypeError, function() {
17 1 >> 1n;
18 }, '1 >> 1n throws TypeError');
19
20 assert.throws(TypeError, function() {
21 Object(1n) >> 1;
22 }, 'Object(1n) >> 1 throws TypeError');
23
24 assert.throws(TypeError, function() {
25 1 >> Object(1n);
26 }, '1 >> Object(1n) throws TypeError');
27
28 assert.throws(TypeError, function() {
29 1n >> Object(1);
30 }, '1n >> Object(1) throws TypeError');
31
32 assert.throws(TypeError, function() {
33 Object(1) >> 1n;
34 }, 'Object(1) >> 1n throws TypeError');
35
36 assert.throws(TypeError, function() {
37 Object(1n) >> Object(1);
38 }, 'Object(1n) >> Object(1) throws TypeError');
39
40 assert.throws(TypeError, function() {
41 Object(1) >> Object(1n);
42 }, 'Object(1) >> Object(1n) throws TypeError');
43
44 assert.throws(TypeError, function() {
45 1n >> NaN;
46 }, '1n >> NaN throws TypeError');
47
48 assert.throws(TypeError, function() {
49 NaN >> 1n;
50 }, 'NaN >> 1n throws TypeError');
51
52 assert.throws(TypeError, function() {
53 1n >> Infinity;
54 }, '1n >> Infinity throws TypeError');
55
56 assert.throws(TypeError, function() {
57 Infinity >> 1n;
58 }, 'Infinity >> 1n throws TypeError');
59
60 assert.throws(TypeError, function() {
61 1n >> true;
62 }, '1n >> true throws TypeError');
63
64 assert.throws(TypeError, function() {
65 true >> 1n;
66 }, 'true >> 1n throws TypeError');
67
68 assert.throws(TypeError, function() {
69 1n >> '1';
70 }, '1n >> "1" throws TypeError');
71
72 assert.throws(TypeError, function() {
73 '1' >> 1n;
74 }, '"1" >> 1n throws TypeError');
75
76 assert.throws(TypeError, function() {
77 1n >> null;
78 }, '1n >> null throws TypeError');
79
80 assert.throws(TypeError, function() {
81 null >> 1n;
82 }, 'null >> 1n throws TypeError');
83
84 assert.throws(TypeError, function() {
85 1n >> undefined;
86 }, '1n >> undefined throws TypeError');
87
88 assert.throws(TypeError, function() {
89 undefined >> 1n;
90 }, 'undefined >> 1n throws TypeError');
91
92 reportCompare(0, 0);