ocaml: phase 6 Option/Result/Bytes extensions (+9 tests, 439 total)
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 29s

Option: join, to_result, some, none.
Result: value, iter, fold.
Bytes: length, get, of_string, to_string, concat, sub — thin alias of
String (SX has no separate immutable byte type).

Ordering fix: Bytes module placed after String so its closures capture
String in scope. Earlier draft put Bytes before String which made
String.* lookups fail with 'not a record/module' (treated as nullary
ctor).
This commit is contained in:
2026-05-08 17:19:16 +00:00
parent f05d405bac
commit 4909ebe2ad
3 changed files with 75 additions and 0 deletions

View File

@@ -1064,6 +1064,26 @@ cat > "$TMPFILE" << 'EPOCHS'
(epoch 3604)
(eval "(ocaml-run-program \"let q = Queue.create () ;; Queue.push 1 q ;; Queue.push 2 q ;; Queue.length q\")")
;; ── Option/Result/Bytes extensions ────────────────────────────
(epoch 3700)
(eval "(ocaml-run \"Option.join (Some (Some 5))\")")
(epoch 3701)
(eval "(ocaml-run \"Option.join None\")")
(epoch 3702)
(eval "(ocaml-run \"Option.to_result \\\"missing\\\" None\")")
(epoch 3703)
(eval "(ocaml-run \"Option.to_result \\\"missing\\\" (Some 7)\")")
(epoch 3704)
(eval "(ocaml-run \"Result.value (Ok 5) 0\")")
(epoch 3705)
(eval "(ocaml-run \"Result.value (Error \\\"e\\\") 99\")")
(epoch 3706)
(eval "(ocaml-run \"Result.fold (fun x -> x * 10) (fun e -> 0) (Ok 5)\")")
(epoch 3707)
(eval "(ocaml-run \"Bytes.length \\\"hello\\\"\")")
(epoch 3708)
(eval "(ocaml-run \"Bytes.concat \\\"-\\\" [\\\"a\\\";\\\"b\\\";\\\"c\\\"]\")")
EPOCHS
OUTPUT=$(timeout 180 "$SX_SERVER" < "$TMPFILE" 2>/dev/null)
@@ -1684,6 +1704,17 @@ check 3602 "Stack.top" '1'
check 3603 "Queue.pop FIFO" '1'
check 3604 "Queue.length" '2'
# ── Option/Result/Bytes extensions ─────────────────────────────
check 3700 "Option.join nested" '("Some" 5)'
check 3701 "Option.join None" '("None")'
check 3702 "Option.to_result None" '("Error" "missing")'
check 3703 "Option.to_result Some" '("Ok" 7)'
check 3704 "Result.value Ok" '5'
check 3705 "Result.value Error fallback" '99'
check 3706 "Result.fold Ok" '50'
check 3707 "Bytes.length" '5'
check 3708 "Bytes.concat" '"a-b-c"'
TOTAL=$((PASS + FAIL))
if [ $FAIL -eq 0 ]; then
echo "ok $PASS/$TOTAL OCaml-on-SX tests passed"