artifacts: add calculators/ — the 30 built calculators (5/variant) + machine-docs + git logs

This commit is contained in:
2026-06-16 15:39:42 +00:00
parent 64bc360fc0
commit bb85aa9f11
728 changed files with 34148 additions and 0 deletions

View File

@ -0,0 +1,44 @@
# STATUS — phase: eval (Builder)
## DONE
Gate: D1 D2 D3 D4 D5 — Adversary PASS @2026-06-15T01:58:00Z. Phase complete.
## What was built
- `calc/evaluator.py``evaluate(node) -> int | float`; `EvalError` for bad nodes / division by zero
- `calc/test_evaluator.py` — 15 unittest cases covering D1D3
- `calc.py` (repo root) — CLI: `python calc.py "<expr>"`
## Commit SHA
See `git log --oneline -1` on origin/main after this push.
## Verify commands (cold — run from repo root)
```bash
python -m unittest -q
# Expected: Ran 56 tests in <N>s / OK
python calc.py "2+3*4" # Expected: 14
python calc.py "(2+3)*4" # Expected: 20
python calc.py "7/2" # Expected: 3.5
python calc.py "4/2" # Expected: 2
python calc.py "1/0" # Expected: prints error to stderr, exits 1
python calc.py "1 +" # Expected: prints error to stderr, exits 1
```
## Gate mapping
| Gate | DoD | Verify |
|------|-----|--------|
| D1 | arithmetic: `+ - * /`, precedence, parens, unary minus | `python -m unittest -q` (TestArithmetic) |
| D2 | true division; `EvalError` on div-by-zero (not bare `ZeroDivisionError`) | `python -m unittest -q` (TestDivision) |
| D3 | whole-valued → int (no `.0`); non-whole → float | `python -m unittest -q` (TestResultType) |
| D4 | `python calc.py "2+3*4"` → 14 exit 0; error → stderr + exit 1 | manual CLI commands above |
| D5 | 56 tests total (lex+parse+eval), 0 failures | `python -m unittest -q` |
## Result type rule (D3)
Division result is normalised: `result = left / right; return int(result) if result == int(result) else result`.
The CLI's `_fmt` calls `str(result)`, so `int` prints as `"2"` and `float` prints as `"3.5"`.