ocaml: phase 4 'assert EXPR' (+3 tests, 487 total)
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 25s

Tokenizer already classified 'assert' as a keyword; this commit wires
it through:
  parser  : parse-prefix dispatches like 'not' — advance, recur, wrap
            as (:assert EXPR).
  eval    : evaluate operand; nil on truthy, host-error 'Assert_failure'
            on false. Caught cleanly by existing try/with.

  assert true; 42                          = 42
  let x = 5 in assert (x = 5); x + 1       = 6
  try (assert false; 0) with _ -> 99       = 99
This commit is contained in:
2026-05-09 00:32:35 +00:00
parent bd2cd8aad1
commit 14b52cfaa7
4 changed files with 26 additions and 0 deletions

View File

@@ -407,6 +407,12 @@ _Newest first._
binary search tree (`type 'a tree = Leaf | Node of 'a * 'a tree *
'a tree`) with insert + in-order traversal. Tests parametric ADT,
recursive match, List.append, List.fold_left.
- 2026-05-09 Phase 4 — `assert EXPR` (+3 tests, 487 total). Tokenizer
already classified `assert` as a keyword; parse-prefix now handles
it like `not` (advance, recur, wrap). Eval evaluates the operand and
returns nil on truthy, raises `Assert_failure` on false (host-side
error so existing try/with handles it). `try (assert false; 0) with
_ -> 99` → 99.
- 2026-05-09 Phase 5.1 — levenshtein.ml baseline (recursive edit
distance, no memo). Sums distances for five short pairs:
("abc","abx")=1 + ("ab","ba")=2 + ("abc","axyc")=2 +