test262/test/built-ins/BigInt/asIntN/bits-toindex.js

30 lines
781 B
JavaScript
Raw Normal View History

2017-09-06 19:52:08 +02:00
// Copyright (C) 2017 Josh Wolfe. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: pending
description: BigInt.asIntN type coercion for bits parameter
info: >
BigInt.asIntN ( bits, bigint )
1. Let bits be ? ToIndex(bits).
features: [BigInt, Symbol, Symbol.toPrimitive]
includes: [typeCoercion.js]
2017-09-06 19:52:08 +02:00
---*/
testCoercibleToIndexZero(function(zero) {
assert.sameValue(BigInt.asIntN(zero, 1n), 0n);
});
2017-09-06 19:52:08 +02:00
testCoercibleToIndexOne(function(one) {
assert.sameValue(BigInt.asIntN(one, 1n), -1n);
});
testCoercibleToIndexFromIndex(3, function(three) {
assert.sameValue(BigInt.asIntN(three, 10n), 2n);
});
testNotCoercibleToIndex(function(error, value) {
assert.throws(error, function() { BigInt.asIntN(value, 0n); });
});