From 5ab44af129f0736be485afda6a2a73ff04660598 Mon Sep 17 00:00:00 2001 From: eunhhu Date: Mon, 19 Oct 2026 01:31:39 +0100 Subject: Pure 027's 5b: an i64 sum exact: the largest i64, 1, -2 and 2 appended to a list of i64 and its sum seen after each: the largest, overflow (no view), the largest less one (past the range midway, the answer), overflow --- tests/check.py | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'tests/check.py') diff --git a/tests/check.py b/tests/check.py index 66b8db4..17f0417 100644 --- a/tests/check.py +++ b/tests/check.py @@ -36,6 +36,7 @@ builds its apps with this compiler.) import argparse import json import random +import struct import subprocess import sys import tempfile @@ -2447,6 +2448,15 @@ def main(): assert r == a % b and math.copysign(1, r) == math.copysign(1, a % b), (a, b, r, a % b) report['floor_divisions'] = len(pairs) + # An i64 sum is exact (Pure 027's 5b): past the range midway, back in it at the end, it is the answer. + (work / 'isum.aup').write_text('record Big {\n v: i64\n}\nstate xs: list of Big\ninput add = message { v: i64 }\n' + 'on add { xs.append(Big { v: add.v }) }\nview total = sum(x.v for x in xs)\n') + compile_module(aup, work / 'isum.aup', work / 'isum.pmod') + steps = ''.join(f"message add {struct.pack('