Debian Codegraph @

tests/auto/qml/ecmascripttests/test262/test/language/expressions/modulus/bigint-modulo-zero.js

raw
1 // Copyright (C) 2017 Robin Templeton. All rights reserved.
2 // This code is governed by the BSD license found in the LICENSE file.
3
4 /*---
5 description: BigInt modulo 0 throws a range error
6 esid: sec-multiplicative-operators-runtime-semantics-evaluation
7 info: |
8 Runtime Semantics: Evaluation
9
10 MultiplicativeExpression: MultiplicativeExpression MultiplicativeOperator ExponentiationExpression
11
12 ...
13 12. Otherwise, MultiplicativeOperator is %; return T::remainder(lnum, rnum).
14 ...
15
16 BigInt::remainder (x, y)
17
18 1. If y is 0n, throw a RangeError exception.
19 2. Return the BigInt representing x modulo y.
20 features: [BigInt]
21 ---*/
22
23 assert.throws(RangeError, function() {
24 1n % 0n
25 });
26
27 assert.throws(RangeError, function() {
28 10n % 0n
29 });
30
31 assert.throws(RangeError, function() {
32 0n % 0n
33 });
34
35 assert.throws(RangeError, function() {
36 1000000000000000000n % 0n
37 });