• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2023-2025 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16function test_module(): void {
17    assertEQ(new BigInt(10).operatorModule(new BigInt(3)), (1n))
18    assertEQ(new BigInt(10).operatorModule(new BigInt(-3)), (1n))
19    assertEQ(new BigInt(-10).operatorModule(new BigInt(3)), (-1n))
20    assertEQ(new BigInt(-10).operatorModule(new BigInt(-3)), (-1n))
21    assertEQ(new BigInt(100).operatorModule(new BigInt(50)), (0n))
22    assertEQ(new BigInt(100).operatorModule(new BigInt(-50)), (0n))
23    assertEQ(new BigInt(-100).operatorModule(new BigInt(50)), (0n))
24    assertEQ(new BigInt(-100).operatorModule(new BigInt(-50)), (0n))
25    assertEQ(new BigInt(3124378143267041203423n).operatorModule(new BigInt(43621978)), (18802883n))
26    assertEQ(new BigInt(-3124378143267041203423n).operatorModule(new BigInt(43621978)), (-18802883n))
27    assertEQ(new BigInt(3124378143267041203423n).operatorModule(new BigInt(-43621978)), (18802883n))
28    assertEQ(new BigInt(-3124378143267041203423n).operatorModule(new BigInt(-43621978)), (-18802883n))
29    assertEQ(new BigInt(100).operatorModule(new BigInt(250)), (100n))
30    assertEQ(new BigInt(-100).operatorModule(new BigInt(250)), (-100n))
31    assertEQ(new BigInt(100).operatorModule(new BigInt(-250)), (100n))
32    assertEQ(new BigInt(-100).operatorModule(new BigInt(-250)), (-100n))
33    assertEQ(new BigInt(0).operatorModule(new BigInt(8)), (0n))
34}
35
36function main() : void {
37    test_module()
38}
39
40