interplane.Get Omega
Read in your language

omega-mv

Omega: a language for verified programs, semantic identity and machine realization. Seed-born work and existing implementations have distinct provenance.

Brought by drakestapleton

branch main Branches Tags History

omega-mv / tests / universal / translation / make_fixtures.py

20 lines · 1406 bytes Raw Blame History
1#!/usr/bin/env python3
2"""Fixture set F1 (spec/universal/translation-v1.md section 8): the exact sources of the reviewed C import
3gate, identified by SHA256. `--check` fails if fixtures-f1.json no longer matches c_import_gate.py."""
4import hashlib, importlib.util, json, sys
5from pathlib import Path
6ROOT = Path(__file__).resolve().parents[3]
7spec = importlib.util.spec_from_file_location('gate', ROOT / 'tests/universal/c_import_gate.py')
8g = importlib.util.module_from_spec(spec); spec.loader.exec_module(g)
9pos = [{'id': 'F1-P%02d' % i, 'sha256': hashlib.sha256(t.encode()).hexdigest(), 'name': n, 'inputs': k,
10 'source': t} for i, (t, n, k) in enumerate(g.POSITIVES)]
11neg = [{'id': 'F1-N%02d' % i, 'sha256': hashlib.sha256(b).hexdigest(), 'bytes': len(b)} for i, b in enumerate(g.NEGATIVES)]
12doc = {'schema': 'omega.universal.fixtures.v1', 'set': 'F1', 'contract': 'spec/universal/translation-v1.md',
13 'from': 'tests/universal/c_import_gate.py', 'positives': pos, 'refusals': neg}
14out = ROOT / 'tests/universal/translation/fixtures-f1.json'
15text = json.dumps(doc, indent=1, ensure_ascii=False) + '\n'
16if sys.argv[1:] == ['--check']:
17 ok = out.read_text() == text
18 print('F1 fixtures %s: %d positives, %d refusals' % ('match' if ok else 'DIFFER', len(pos), len(neg)))
19 sys.exit(0 if ok else 1)
20out.write_text(text); print('wrote', out, len(pos), 'positives', len(neg), 'refusals')