ocaml: phase 5.1 safe_div.ml baseline + Result.equal/compare/iter_error (+3 tests, 592 total)
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 22s

safe_div.ml: integer division returning Result. Sum-safe folds pairs,
skipping the Error branches.

  [(10,2); (20,4); (30,0); (50,5)]   ->  5 + 5 + 0 + 10 = 20

Result module additions (mirroring real OCaml's signatures):

  equal eq_ok eq_err a b
  compare cmp_ok cmp_err a b      Ok < Error (i.e. Ok x compared to
                                  Error e returns -1)
  iter_error f r

  Result.equal (=) (=) (Ok 1) (Ok 1)              = true
  Result.compare compare compare (Ok 5) (Ok 3)    = 1
  Result.compare compare compare (Ok 1) (Error _) = -1

30 baseline programs total.
This commit is contained in:
2026-05-09 06:47:47 +00:00
parent 98ba772acd
commit 0c3b5d21fa
5 changed files with 54 additions and 0 deletions

View File

@@ -1472,6 +1472,14 @@ cat > "$TMPFILE" << 'EPOCHS'
(epoch 5224)
(eval "(ocaml-run \"List.compare compare [] []\")")
;; ── Result.equal / Result.compare ────────────────────────────
(epoch 5230)
(eval "(ocaml-run \"Result.equal (=) (=) (Ok 1) (Ok 1)\")")
(epoch 5231)
(eval "(ocaml-run \"Result.compare compare compare (Ok 5) (Ok 3)\")")
(epoch 5232)
(eval "(ocaml-run \"Result.compare compare compare (Ok 1) (Error \\\"fail\\\")\")")
EPOCHS
OUTPUT=$(timeout 360 "$SX_SERVER" < "$TMPFILE" 2>/dev/null)
@@ -2341,6 +2349,11 @@ check 5222 "List.compare [1;2;3] [1;2;4]" '-1'
check 5223 "List.compare [1;2] [1;2;3]" '-1'
check 5224 "List.compare [] []" '0'
# ── Result.equal / Result.compare ───────────────────────────────
check 5230 "Result.equal Ok 1 Ok 1" 'true'
check 5231 "Result.compare Ok 5 Ok 3" '1'
check 5232 "Result.compare Ok < Error" '-1'
TOTAL=$((PASS + FAIL))
if [ $FAIL -eq 0 ]; then
echo "ok $PASS/$TOTAL OCaml-on-SX tests passed"