| 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-addition-operator-plus-runtime-semantics-evaluation |
| 5 |
description: Mixing BigInt and Number produces a TypeError for addition operator |
| 6 |
features: [BigInt] |
| 7 |
info: | |
| 8 |
Let lprim be ? ToPrimitive(lval). |
| 9 |
Let rprim be ? ToPrimitive(rval). |
| 10 |
... |
| 11 |
Let lnum be ? ToNumeric(lprim) |
| 12 |
Let rnum be ? ToNumeric(rprim) |
| 13 |
If Type(lnum) does not equal Type(rnum), throw a TypeError exception. |
| 14 |
---*/ |
| 15 |
|
| 16 |
assert.throws(TypeError, function() { 1n + 1; }, "1n + 1 throws TypeError"); |
| 17 |
assert.throws(TypeError, function() { 1 + 1n; }, "1 + 1n throws TypeError"); |
| 18 |
assert.throws(TypeError, function() { Object(1n) + 1; }, "Object(1n) + 1 throws TypeError"); |
| 19 |
assert.throws(TypeError, function() { 1 + Object(1n); }, "1 + Object(1n) throws TypeError"); |
| 20 |
assert.throws(TypeError, function() { 1n + Object(1); }, "1n + Object(1) throws TypeError"); |
| 21 |
assert.throws(TypeError, function() { Object(1) + 1n; }, "Object(1) + 1n throws TypeError"); |
| 22 |
assert.throws(TypeError, function() { Object(1n) + Object(1); }, "Object(1n) + Object(1) throws TypeError"); |
| 23 |
assert.throws(TypeError, function() { Object(1) + Object(1n); }, "Object(1) + Object(1n) throws TypeError"); |
| 24 |
assert.throws(TypeError, function() { 1n + NaN; }, "1n + NaN throws TypeError"); |
| 25 |
assert.throws(TypeError, function() { NaN + 1n; }, "NaN + 1n throws TypeError"); |
| 26 |
assert.throws(TypeError, function() { 1n + Infinity; }, "1n + Infinity throws TypeError"); |
| 27 |
assert.throws(TypeError, function() { Infinity + 1n; }, "Infinity + 1n throws TypeError"); |
| 28 |
assert.throws(TypeError, function() { 1n + true; }, "1n + true throws TypeError"); |
| 29 |
assert.throws(TypeError, function() { true + 1n; }, "true + 1n throws TypeError"); |
| 30 |
assert.throws(TypeError, function() { 1n + null; }, "1n + null throws TypeError"); |
| 31 |
assert.throws(TypeError, function() { null + 1n; }, "null + 1n throws TypeError"); |
| 32 |
assert.throws(TypeError, function() { 1n + undefined; }, "1n + undefined throws TypeError"); |
| 33 |
assert.throws(TypeError, function() { undefined + 1n; }, "undefined + 1n throws TypeError"); |