| ... | ... | @@ -1562,3 +1562,29 @@ test "big.int pow" { |
| 1562 | 1562 | try testing.expectEqual(@as(i32, 1), try a.to(i32)); |
| 1563 | 1563 | } |
| 1564 | 1564 | } |
| 1565 | |
| 1566 | test "bigint regression test for 1 limb overflow with alias" { |
| 1567 | // Note these happen to be two consecutive Fibonacci sequence numbers, the |
| 1568 | // first two whose sum exceeds 2**64. |
| 1569 | var a = try Managed.initSet(testing.allocator, 7540113804746346429); |
| 1570 | defer a.deinit(); |
| 1571 | var b = try Managed.initSet(testing.allocator, 12200160415121876738); |
| 1572 | defer b.deinit(); |
| 1573 | |
| 1574 | try a.add(a.toConst(), b.toConst()); |
| 1575 | |
| 1576 | try testing.expect(a.toConst().orderAgainstScalar(19740274219868223167) == .eq); |
| 1577 | } |
| 1578 | |
| 1579 | test "bigint regression test for something else with alias" { |
| 1580 | // Note these happen to be two consecutive Fibonacci sequence numbers, the |
| 1581 | // second of which is the first such number to exceed 2**192. |
| 1582 | var a = try Managed.initSet(testing.allocator, 5611500259351924431073312796924978741056961814867751431689); |
| 1583 | defer a.deinit(); |
| 1584 | var b = try Managed.initSet(testing.allocator, 9079598147510263717870894449029933369491131786514446266146); |
| 1585 | defer b.deinit(); |
| 1586 | |
| 1587 | try a.add(a.toConst(), b.toConst()); |
| 1588 | |
| 1589 | try testing.expect(a.toConst().orderAgainstScalar(14691098406862188148944207245954912110548093601382197697835) == .eq); |
| 1590 | } |