Complete 3axis tutorial native and Web/WASM parity tools

This commit is contained in:
2026-08-24 14:01:30 +08:00
parent 938654b19d
commit 7e90142b63
147 changed files with 17639 additions and 557 deletions

View File

@@ -0,0 +1,32 @@
import hashlib
import json
import unittest
from pathlib import Path
from generate_source_semantics_contract import OUTPUT, canonical, generate
ROOT = Path(__file__).resolve().parents[1]
class SourceSemanticsContractTests(unittest.TestCase):
def test_contract(self):
report = json.loads(OUTPUT.read_text(encoding="utf-8"))
self.assertEqual(report["schema"], "linuxcnc-source-semantics-contract.v1")
self.assertEqual(report["status"], "verified")
self.assertEqual(report["context_id"], "linuxcnc-2.10.0-pre0-wasm-m1-py-c1")
self.assertTrue(any(rule["id"] == "axis_open_file_optional" for rule in report["rules"]))
self.assertTrue(any(rule["id"] == "halfile_missing_classification" for rule in report["rules"]))
self.assertEqual(report["control_panel_contract"]["projection_only"], True)
self.assertTrue(all(item["status"] == "present" for item in report["inputs"]))
def test_self_hash_and_determinism(self):
before = OUTPUT.read_bytes()
report = generate()
self.assertEqual(before, OUTPUT.read_bytes())
unsigned = {key: value for key, value in report.items() if key != "report_sha256"}
self.assertEqual(report["report_sha256"], hashlib.sha256(canonical(unsigned).encode()).hexdigest())
if __name__ == "__main__":
unittest.main()