aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authoreunhhu <[email protected]>2026-10-18 22:11:12 +0100
committereunhhu <[email protected]>2026-10-18 22:11:12 +0100
commita72a1a7acdf6c5ecc4a6668f6b9a3af16ce48555 (patch)
tree1586219b4b49893faab58171292d8697cab1e153 /tests
parentda0d7514b058f1baa99a8bcc8f9e23b43cac12de (diff)
downloadpure-a72a1a7acdf6c5ecc4a6668f6b9a3af16ce48555.tar.gz
pure-a72a1a7acdf6c5ecc4a6668f6b9a3af16ce48555.zip
Module format v7, 027's 4e: a view of any value: a view's and a column's type a record field's (number, text, bool, i64, list, bytes; PURE_VIEW_TABLE now PURE_VIEW_LIST), a view entry 20 bytes (its table + 1, its items' record + 1, its list state + 1); a list view's rows a list state's items as they are or filtered (its record's fields its columns, made at load: each reads its item's field as it is), a list state's map (its columns following it, as tables were), or the items of a list its block leaves (copied into a kept list once a change, its rows and cells kept until the next); a list cell lent in its items' stored form (pure_app_cell_items, pure_items_next reading it), bytes as a text is; a pointing only at a list view over a state; pure-run writes bytes as hex and a list cell as an array of objects, pure-serve a bytes view as application/octet-stream and, in JSON, bytes as hex strings and list cells as arrays of objects; a hole closed: a view without a body never began its growth anew, so in a snapshot's reader (pure-serve's views) reading a kept list's list failed as memory (unreachable before 4e: no such view could be written), now marked a body at load; unit test list_views (as it is, filtered, computed, a map's list and bytes columns, a bytes view, six refused); check server_trees keeps its forests in a stored list shown by list views over HTTP against the model, a restart too; counts: the first build's bank tables rose (field +5.9%: view_of left inline at its seventh caller, serve's put_bytes too), so view_of is inlined, the made columns' and computed lists' paths and serve's new writers kept apart, a computed list's rows held as a filter's; b37 against b35 within 0.001% with batches and without; the bank's queries (s35 on the 4d aup's module, s37 on 4e's, six each in turns) field +0.67%, found +0.43%, large +0.31%, the rest within 0.20%; 008 and 027
Diffstat (limited to 'tests')
-rw-r--r--tests/check.py38
1 files changed, 35 insertions, 3 deletions
diff --git a/tests/check.py b/tests/check.py
index 1e14e12..3f2fee1 100644
--- a/tests/check.py
+++ b/tests/check.py
@@ -3684,6 +3684,7 @@ state nodes = 0
state total = 0
state deepest = 0
state name_bytes = 0
+state kept: list of Node
input tree = message {
label: text
roots: list of Node
@@ -3699,13 +3700,23 @@ fn walk(x, depth) {
on tree {
require tree.label != "refuse"
- for r in tree.roots { walk(r, 1) }
+ for r in tree.roots {
+ walk(r, 1)
+ kept.append(r)
+ }
}
view count = nodes
view sum = total
view depth = deepest
view named = name_bytes
+view forest = kept
+view top = each k in kept {
+ label = k.name
+ kids = k.kids
+ tag = k.tag
+}
+view mark = bytes("pure")
'''
@@ -3713,7 +3724,9 @@ def server_trees(aup, pure, work):
"""A message's rows whose records hold lists (027's 4a): a JSON forest
read straight into the event's lists, nested to any depth up to 64, and
walked by a function that calls itself, a field of bytes among them
- (027's 4b). Random forests (names with
+ (027's 4b), and kept in a stored list its list views show (027's 4e:
+ the list as it is and a map, nested arrays and bytes as hex in JSON, a
+ bytes view as its bytes). Random forests (names with
escapes and characters past ASCII, fields left out taking their
defaults) against a model walking them in the same order; a require
refusing one leaves everything as it was; malformed trees (a list field
@@ -3738,6 +3751,20 @@ def server_trees(aup, pure, work):
def views(port):
return tuple(float(call(port, 'GET', f'/views/{v}')[2]) for v in ('count', 'sum', 'depth', 'named'))
+ def stored(node): # a node as the stored list holds it: defaults filled, bytes as hex
+ return {'name': node['name'], 'tag': node.get('tag', '-').encode().hex(), 'n': node.get('n', 0),
+ 'kids': [stored(k) for k in node.get('kids', [])]}
+ kept = []
+
+ def lists_shown(port):
+ forest = json.loads(call(port, 'GET', '/views/forest?count=100000')[2])
+ top = json.loads(call(port, 'GET', '/views/top?count=100000')[2])
+ assert forest['rows'] == top['rows'] == len(kept) and forest['items'] == kept, (forest['rows'], len(kept))
+ want = [{'label': k['name'], 'kids': k['kids'], 'tag': k['tag']} for k in kept]
+ assert top['items'] == want, next((a, b) for a, b in zip(top['items'], want) if a != b)
+ status, _, mark = call(port, 'GET', '/views/mark')
+ assert (status, mark) == (200, b'pure'), (status, mark)
+
rng = random.Random(44)
names = ['', 'a', 'node', '빨리', 'a "quoted" \\ name', 'tab\there', '😀', 'line\nbreak', 'é']
@@ -3781,9 +3808,11 @@ def server_trees(aup, pure, work):
else:
assert (status, error) == (200, 'none'), (status, error)
model = after
+ kept += [stored(r) for r in roots]
sent += 1
if i % 25 == 0:
assert views(host.port) == tuple(model), (views(host.port), model)
+ lists_shown(host.port)
deep = {'name': 'z'}
for _ in range(63):
deep = {'name': 'z', 'kids': [deep]}
@@ -3793,16 +3822,19 @@ def server_trees(aup, pure, work):
assert call(host.port, 'POST', '/inputs/tree', json.dumps(body).encode())[:2] == want, body
assert call(host.port, 'POST', '/inputs/tree', json.dumps({'label': 'x', 'roots': [deep]}).encode())[:2] == (200, 'none')
walk(deep, 1, model)
+ kept.append(stored(deep))
assert views(host.port) == tuple(model) and model[2] == 64
+ lists_shown(host.port)
finally:
host.stop()
host = HttpHost([pure / 'build/pure-serve', '--module', module, '--store', store])
try:
assert views(host.port) == tuple(model)
+ lists_shown(host.port)
finally:
host.stop()
assert sent > 200 and refused > 10
- return {'forests': sent, 'refused': refused, 'nodes': model[0], 'deepest': model[2]}
+ return {'forests': sent, 'refused': refused, 'nodes': model[0], 'deepest': model[2], 'kept': len(kept)}
ARGUED = '''
record Account {