Debian Codegraph @

tests/auto/qml/ecmascripttests/test262/test/language/expressions/bitwise-and/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-binary-bitwise-operators-runtime-semantics-evaluation
5 description: Mixing BigInt and Number produces a TypeError for bitwise-and 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
13 assert.throws(TypeError, function() { 1n & 1; }, "1n & 1 throws TypeError");
14 assert.throws(TypeError, function() { 1 & 1n; }, "1 & 1n throws TypeError");
15 assert.throws(TypeError, function() { Object(1n) & 1; }, "Object(1n) & 1 throws TypeError");
16 assert.throws(TypeError, function() { 1 & Object(1n); }, "1 & Object(1n) throws TypeError");
17 assert.throws(TypeError, function() { 1n & Object(1); }, "1n & Object(1) throws TypeError");
18 assert.throws(TypeError, function() { Object(1) & 1n; }, "Object(1) & 1n throws TypeError");
19 assert.throws(TypeError, function() { Object(1n) & Object(1); }, "Object(1n) & Object(1) throws TypeError");
20 assert.throws(TypeError, function() { Object(1) & Object(1n); }, "Object(1) & Object(1n) throws TypeError");
21 assert.throws(TypeError, function() { 1n & NaN; }, "1n & NaN throws TypeError");
22 assert.throws(TypeError, function() { NaN & 1n; }, "NaN & 1n throws TypeError");
23 assert.throws(TypeError, function() { 1n & Infinity; }, "1n & Infinity throws TypeError");
24 assert.throws(TypeError, function() { Infinity & 1n; }, "Infinity & 1n throws TypeError");
25 assert.throws(TypeError, function() { 1n & true; }, "1n & true throws TypeError");
26 assert.throws(TypeError, function() { true & 1n; }, "true & 1n throws TypeError");
27 assert.throws(TypeError, function() { 1n & "1"; }, '1n & "1" throws TypeError');
28 assert.throws(TypeError, function() { "1" & 1n; }, '"1" & 1n throws TypeError');
29 assert.throws(TypeError, function() { 1n & null; }, "1n & null throws TypeError");
30 assert.throws(TypeError, function() { null & 1n; }, "null & 1n throws TypeError");
31 assert.throws(TypeError, function() { 1n & undefined; }, "1n & undefined throws TypeError");
32 assert.throws(TypeError, function() { undefined & 1n; }, "undefined & 1n throws TypeError");