diff options
| author | eunhhu <[email protected]> | 2026-10-19 07:05:44 +0100 |
|---|---|---|
| committer | eunhhu <[email protected]> | 2026-10-19 07:05:44 +0100 |
| commit | 24e3994b4c845831f867430cc4bb4c6e1e564a6d (patch) | |
| tree | 2df643661d701baf1f6402deaaab557a475507d8 /tests | |
| parent | 3f870ba7abf4e8abd5ddfeced58c64a2e2b86cec (diff) | |
| download | aup-24e3994b4c845831f867430cc4bb4c6e1e564a6d.tar.gz aup-24e3994b4c845831f867430cc4bb4c6e1e564a6d.zip | |
Names together without a core change (140's frictions): lets' lists declared together (let a, b: list of R, a let each, empty as it begins; given elements refused), and targets together with fields and items among them (xs[i].x, xs[i].y = a, b; a, xs[i] = ...): the values first, each into a let of its own (a literal straight), then each target left to right as Python's; names alone are S_ASSIGNS as before; frictions in make check, two diagnostics; no module of aup's, Pure's or Vega's changes
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/check.py | 83 |
1 files changed, 83 insertions, 0 deletions
diff --git a/tests/check.py b/tests/check.py index e299911..72dee99 100644 --- a/tests/check.py +++ b/tests/check.py @@ -77,6 +77,9 @@ DIAGNOSTICS = [ ('state y: i64\nview v = 0xffffffffffffffff + y\n', '2:10', "the number is past an i64's range"), ('state a = 0\nstate b = 0\non frame {\n a, b = 1\n}\n', '4:3', '2 names take 2 values, not 1'), ('state a = 0\non frame {\n a, a = 1, 2\n}\n', '3:6', "'a' is named twice"), + ('state a = 0\non frame {\n let xs, ys: list of number = [1]\n}\n', '3:30', + 'lists declared together begin empty: give each its elements apart'), + ('state a = 0\non frame {\n let xs, xs: list of number\n}\n', '3:11', "'xs' is named twice"), ('state s: text\nstate a = 0\non frame {\n s, a = "x", 1\n}\n', '4:3', "'s' takes its value apart"), ('state t: text\nstate c: cursor in t\non frame {\n let a, b = 1, c\n}\n', '4:17', 'a let holds a number, a bool, an i64, an index, bytes, text, a list or a record, not a cursor'), @@ -645,6 +648,53 @@ on m { } ''' +FRICTIONS = '''record P { + x = 0 +} +record B { + x = 0 + y = 0 +} +state total = 0 +state n = 0 +state bs: list of B +state a = 0 +state b = 0 +state i = 0 +input go = message { k: u32 } +on go { + if bs.count == 0 { bs.append(B {}) } + bs.append(B {}) + bs[0].x, bs[0].y = go.k, go.k * 2 + a, bs[1].x = bs[0].y, a + 1 + i, bs[i].y = 1, 7 + a, b = b, a + let ns: list of number + ns.append(0) + ns.append(0) + ns[0], ns[1] = 3, go.k + b = b + ns[0] * 100 + ns[1] + let xs, ys: list of number + let ps, qs: list of P + for j in 0 .. go.k { + xs.append(j) + ys.append(j * 2) + ps.append(P { x: j }) + } + if go.k > 1 { + let inner, outer: list of number + inner.append(go.k) + outer.append(1) + n = inner.count * 10 + outer.count + inner[0] + } + let t = 0 + for v in xs { t = t + v } + for v in ys { t = t + v * 100 } + for p in ps { t = t + p.x * 10000 } + total = t + qs.count +} +''' + INNER_LISTS = '''record Seen { node = 0 depth = 0 @@ -1732,6 +1782,38 @@ def rows_at(aup, pure_run, work, events=200): return events +def frictions(aup, pure_run, work, events=100): + """140's frictions written away in aup alone, no core change: lets' lists declared together (let a, b: list of R), + each its own and empty as it begins, in inner blocks too; targets together with fields and items among them + (xs[i].x, xs[i].y = a, b; a, xs[i] = ...), the values first, then each target left to right as Python's. Each event + against Python's.""" + import random + import struct + path = work / 'frictions.pmod' + (work / 'frictions.aup').write_text(FRICTIONS) + compile_module(aup, work / 'frictions.aup', path) + rng = random.Random(140) + asked = [rng.randrange(0, 9) for _ in range(events)] + lines = run(pure_run, path, stdin=''.join(f"message go {struct.pack('<I', k).hex()}\n" for k in asked)).stdout.splitlines() + assert len(lines) == events + n, bs, a, b, i = 0, [], 0, 0, 0 + for k, line in zip(asked, lines): + state = json.loads(line) + if k > 1: n = 10 + 1 + k + bs += [{'x': 0, 'y': 0}] * (2 if not bs else 1) + bs = [dict(x) for x in bs] + bs[0]['x'], bs[0]['y'] = k, k * 2 + a, bs[1]['x'] = bs[0]['y'], a + 1 + i, bs[i]['y'] = 1, 7 + a, b = b, a + ns = [0, 0] + ns[0], ns[1] = 3, k + b = b + ns[0] * 100 + ns[1] + want = {'total': sum(range(k)) * (1 + 200 + 10000), 'n': n, 'bs': bs, 'a': a, 'b': b, 'i': i} + assert state['fault'] == 'none' and {key: state['states'][key] for key in want} == want, (k, state['states']) + return events + + def bytes_compared(aup, pure_run, work, events=400): """Bytes compared (Pure's TEXT_COMPARE with PURE_COMPARE_BYTES, after 140's DNS and HTTP): random bytes, 0x00 and 0xff among them, in the six relations, against literals on either side and a string with a format (a string where @@ -2927,6 +3009,7 @@ def main(): report['bytes_compared'] = bytes_compared(aup, pure_run, work) report['inner_lists'] = inner_lists(aup, pure_run, work) report['rows_at'] = rows_at(aup, pure_run, work) + report['frictions'] = frictions(aup, pure_run, work) report['bytes_state'] = bytes_state(aup, pure_run, work) report['stored_nested'] = stored_nested(aup, pure_run, work, range(6)) report['documents'] = documents_model(aup, pure_run, work, range(4)) |
