ocaml: phase 6 Stack + Queue modules (+5 tests, 430 total)
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 35s

Stack: ref-holding-list LIFO. push/pop/top/length/is_empty/clear.
Queue: two-list (front, back) amortised O(1) queue. push/pop/length/
is_empty/clear. Both in OCaml syntax in runtime.sx.
This commit is contained in:
2026-05-08 17:03:32 +00:00
parent ffa74399fd
commit f05d405bac
3 changed files with 71 additions and 0 deletions

View File

@@ -1052,6 +1052,18 @@ cat > "$TMPFILE" << 'EPOCHS'
(epoch 3502)
(eval "(ocaml-run-program \"let b = Buffer.create 16 ;; Buffer.add_string b \\\"x\\\" ;; Buffer.clear b ;; Buffer.contents b\")")
;; ── Stack + Queue modules ─────────────────────────────────────
(epoch 3600)
(eval "(ocaml-run-program \"let s = Stack.create () ;; Stack.push 1 s ;; Stack.push 2 s ;; Stack.push 3 s ;; Stack.pop s\")")
(epoch 3601)
(eval "(ocaml-run-program \"let s = Stack.create () ;; Stack.push 1 s ;; Stack.push 2 s ;; Stack.length s\")")
(epoch 3602)
(eval "(ocaml-run-program \"let s = Stack.create () ;; Stack.push 1 s ;; Stack.top s\")")
(epoch 3603)
(eval "(ocaml-run-program \"let q = Queue.create () ;; Queue.push 1 q ;; Queue.push 2 q ;; Queue.push 3 q ;; Queue.pop q\")")
(epoch 3604)
(eval "(ocaml-run-program \"let q = Queue.create () ;; Queue.push 1 q ;; Queue.push 2 q ;; Queue.length q\")")
EPOCHS
OUTPUT=$(timeout 180 "$SX_SERVER" < "$TMPFILE" 2>/dev/null)
@@ -1665,6 +1677,13 @@ check 3500 "Buffer concat 'Hello, World'" '"Hello, World"'
check 3501 "Buffer.length 3" '3'
check 3502 "Buffer.clear empties" '""'
# ── Stack + Queue ──────────────────────────────────────────────
check 3600 "Stack.pop LIFO" '3'
check 3601 "Stack.length" '2'
check 3602 "Stack.top" '1'
check 3603 "Queue.pop FIFO" '1'
check 3604 "Queue.length" '2'
TOTAL=$((PASS + FAIL))
if [ $FAIL -eq 0 ]; then
echo "ok $PASS/$TOTAL OCaml-on-SX tests passed"