ocaml: phase 4 'assert EXPR' (+3 tests, 487 total)
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 25s
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:
@@ -1202,6 +1202,14 @@ cat > "$TMPFILE" << 'EPOCHS'
|
||||
(epoch 4922)
|
||||
(eval "(ocaml-run \"let s = \\\"hi\\\" in let n = ref 0 in for i = 0 to String.length s - 1 do n := !n + Char.code s.[i] done; !n\")")
|
||||
|
||||
;; ── assert ────────────────────────────────────────────────────
|
||||
(epoch 4930)
|
||||
(eval "(ocaml-run \"assert true; 42\")")
|
||||
(epoch 4931)
|
||||
(eval "(ocaml-run \"let x = 5 in assert (x = 5); x + 1\")")
|
||||
(epoch 4932)
|
||||
(eval "(ocaml-run \"try (assert false; 0) with _ -> 99\")")
|
||||
|
||||
EPOCHS
|
||||
|
||||
OUTPUT=$(timeout 360 "$SX_SERVER" < "$TMPFILE" 2>/dev/null)
|
||||
@@ -1906,6 +1914,11 @@ check 4920 "s.[0] hello" '"h"'
|
||||
check 4921 "Char.code s.[2] abc" '99'
|
||||
check 4922 "for i s.[i] sum hi" '209'
|
||||
|
||||
# ── assert ───────────────────────────────────────────────────────
|
||||
check 4930 "assert true; 42" '42'
|
||||
check 4931 "assert (x = 5); x + 1" '6'
|
||||
check 4932 "try (assert false; ...) with" '99'
|
||||
|
||||
TOTAL=$((PASS + FAIL))
|
||||
if [ $FAIL -eq 0 ]; then
|
||||
echo "ok $PASS/$TOTAL OCaml-on-SX tests passed"
|
||||
|
||||
Reference in New Issue
Block a user