ocaml: phase 6 Map/Set extensions iter/fold/filter/union/inter (+4 tests, 422 total)
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 32s
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 32s
Map.Make: iter, fold, map, filter, is_empty added.
Set.Make: iter, fold, filter, is_empty, union, inter added.
All written in OCaml inside the existing functor bodies. Tested:
IntMap.fold (fun k v acc -> acc + v) m 0 = 30
IntSet.elements (IntSet.union {1,2} {2,3}) = [1; 2; 3]
IntSet.elements (IntSet.inter {1,2,3} {2,3,4}) = [2; 3]
This commit is contained in:
@@ -1034,6 +1034,16 @@ cat > "$TMPFILE" << 'EPOCHS'
|
||||
(epoch 3303)
|
||||
(eval "(ocaml-run-program \"module IntOrd = struct let compare a b = compare a b end ;; module IntSet = Set.Make(IntOrd) ;; IntSet.mem 2 (IntSet.add 3 (IntSet.add 1 (IntSet.add 2 IntSet.empty)))\")")
|
||||
|
||||
;; ── Map/Set fold/iter/filter/union/inter ──────────────────────
|
||||
(epoch 3400)
|
||||
(eval "(ocaml-run-program \"module IntOrd = struct let compare a b = compare a b end ;; module IntMap = Map.Make(IntOrd) ;; let m = IntMap.add 1 10 (IntMap.add 2 20 IntMap.empty) ;; IntMap.fold (fun k v acc -> acc + v) m 0\")")
|
||||
(epoch 3401)
|
||||
(eval "(ocaml-run-program \"module IntOrd = struct let compare a b = compare a b end ;; module IntMap = Map.Make(IntOrd) ;; let m = IntMap.add 1 10 IntMap.empty ;; IntMap.is_empty m\")")
|
||||
(epoch 3402)
|
||||
(eval "(ocaml-run-program \"module IntOrd = struct let compare a b = compare a b end ;; module IntSet = Set.Make(IntOrd) ;; let a = IntSet.add 1 (IntSet.add 2 IntSet.empty) ;; let b = IntSet.add 2 (IntSet.add 3 IntSet.empty) ;; IntSet.elements (IntSet.union a b)\")")
|
||||
(epoch 3403)
|
||||
(eval "(ocaml-run-program \"module IntOrd = struct let compare a b = compare a b end ;; module IntSet = Set.Make(IntOrd) ;; let a = IntSet.add 1 (IntSet.add 2 (IntSet.add 3 IntSet.empty)) ;; let b = IntSet.add 2 (IntSet.add 3 (IntSet.add 4 IntSet.empty)) ;; IntSet.elements (IntSet.inter a b)\")")
|
||||
|
||||
EPOCHS
|
||||
|
||||
OUTPUT=$(timeout 180 "$SX_SERVER" < "$TMPFILE" 2>/dev/null)
|
||||
@@ -1636,6 +1646,12 @@ check 3301 "Map.cardinal" '2'
|
||||
check 3302 "Set.elements sorted" '(1 2 3)'
|
||||
check 3303 "Set.mem" 'true'
|
||||
|
||||
# ── Map/Set fold/iter/filter/union/inter ───────────────────────
|
||||
check 3400 "Map.fold sum" '30'
|
||||
check 3401 "Map.is_empty false" 'false'
|
||||
check 3402 "Set.union" '(1 2 3)'
|
||||
check 3403 "Set.inter" '(2 3)'
|
||||
|
||||
TOTAL=$((PASS + FAIL))
|
||||
if [ $FAIL -eq 0 ]; then
|
||||
echo "ok $PASS/$TOTAL OCaml-on-SX tests passed"
|
||||
|
||||
Reference in New Issue
Block a user