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

30 lines
786 B
JavaScript
Raw Normal View History

// 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.asUintN type coercion for bits parameter
info: >
BigInt.asUintN ( bits, bigint )
1. Let bits be ? ToIndex(bits).
features: [BigInt, Symbol, Symbol.toPrimitive]
includes: [typeCoercion.js]
---*/
testCoercibleToIndexZero(function(zero) {
assert.sameValue(BigInt.asUintN(zero, 1n), 0n);
});
testCoercibleToIndexOne(function(one) {
2017-09-21 20:42:23 +02:00
assert.sameValue(BigInt.asUintN(one, 1n), 1n);
});
testCoercibleToIndexFromIndex(3, function(three) {
assert.sameValue(BigInt.asUintN(three, 10n), 2n);
});
testNotCoercibleToIndex(function(error, value) {
assert.throws(error, function() { BigInt.asUintN(value, 0n); });
});