From f6f088b1b9a8aba9a361edb00f98fe5ed29dce82 Mon Sep 17 00:00:00 2001 From: Simon Cruanes Date: Sun, 8 Feb 2026 05:38:24 +0000 Subject: [PATCH] Fix test compilation issues and simplify result tests - Fixed CCByte_slice tests: moved 'open CCByte_slice' after include T to avoid shadowing test framework's 'get' function - Fixed missing ;; terminators in t_option.ml and t_list.ml - Removed non-existent CCList.split_while function tests - Changed CCList.sorted_uniq to sort_uniq (correct function name) - Simplified t_result.ml additions to focus on core functionality - All tests now compile successfully with OCaml 5.3.0 --- tests/core/t_byte_slice.ml | 4 +--- tests/core/t_list.ml | 21 ++++----------------- tests/core/t_option.ml | 2 +- tests/core/t_pair.ml | 4 +--- tests/core/t_ref.ml | 4 +--- tests/core/t_result.ml | 8 ++++++++ 6 files changed, 16 insertions(+), 27 deletions(-) diff --git a/tests/core/t_byte_slice.ml b/tests/core/t_byte_slice.ml index 5a66bc39..8572e688 100644 --- a/tests/core/t_byte_slice.ml +++ b/tests/core/t_byte_slice.ml @@ -1,9 +1,7 @@ -(* Tests for CCByte_slice *) -open CCByte_slice module T = (val Containers_testlib.make ~__FILE__ ()) include T +open CCByte_slice;; -(* Test basic creation *) t @@ fun () -> let bs = Bytes.of_string "hello" in let sl = create bs in diff --git a/tests/core/t_list.ml b/tests/core/t_list.ml index 85f95ded..fa3d0448 100644 --- a/tests/core/t_list.ml +++ b/tests/core/t_list.ml @@ -1161,7 +1161,7 @@ eq ~pp_start:(fun fmt () -> Format.fprintf fmt "[") ~pp_stop:(fun fmt () -> Format.fprintf fmt "]") CCFormat.int)) - [ 1; 2; 3 ]) + [ 1; 2; 3 ]);; (* Additional edge case and property tests *) @@ -1195,19 +1195,6 @@ eq [4; 5] (CCList.drop_while (fun x -> x < 4) [1; 2; 3; 4; 5]);; eq [1; 2; 3] (CCList.drop_while (fun x -> x < 0) [1; 2; 3]);; eq [] (CCList.drop_while (fun _ -> true) [1; 2; 3]);; -(* Test split_while *) -eq ([1; 2; 3], [4; 5; 6]) - (CCList.split_while (fun x -> x < 4) [1; 2; 3; 4; 5; 6]) -;; - -eq ([], [1; 2; 3]) - (CCList.split_while (fun x -> x < 0) [1; 2; 3]) -;; - -eq ([1; 2; 3], []) - (CCList.split_while (fun _ -> true) [1; 2; 3]) -;; - (* Test find_map *) eq (Some 4) (CCList.find_map (fun x -> if x > 3 then Some (x * 2) else None) [1; 2; 3; 4; 5]) @@ -1288,9 +1275,9 @@ eq [1; 2; 3; 2; 1] (CCList.uniq ~eq:Int.equal [1; 1; 2; 3; 3; 2; 1]) ;; -(* Test sorted_uniq *) +(* Test sort_uniq *) eq [1; 2; 3; 4] - (CCList.sorted_uniq ~cmp:Int.compare [1; 1; 2; 2; 3; 3; 4; 4]) + (CCList.sort_uniq ~cmp:Int.compare [1; 1; 2; 2; 3; 3; 4; 4]) ;; (* Test init with edge cases *) @@ -1336,7 +1323,7 @@ q Q.(list small_int) (fun l -> q Q.(list small_int) (fun l -> let sorted = List.sort Int.compare l in - let uniq = CCList.sorted_uniq ~cmp:Int.compare sorted in + let uniq = CCList.sort_uniq ~cmp:Int.compare sorted in List.length uniq <= List.length l );; diff --git a/tests/core/t_option.ml b/tests/core/t_option.ml index 0314c119..fabd8457 100644 --- a/tests/core/t_option.ml +++ b/tests/core/t_option.ml @@ -27,7 +27,7 @@ t @@ fun () -> flatten None = None;; t @@ fun () -> flatten (Some None) = None;; t @@ fun () -> flatten (Some (Some 1)) = Some 1;; t @@ fun () -> return_if false 1 = None;; -t @@ fun () -> return_if true 1 = Some 1 +t @@ fun () -> return_if true 1 = Some 1;; (* Additional comprehensive tests for CCOption *) diff --git a/tests/core/t_pair.ml b/tests/core/t_pair.ml index 228f8a48..b7082f03 100644 --- a/tests/core/t_pair.ml +++ b/tests/core/t_pair.ml @@ -1,9 +1,7 @@ -(* Tests for CCPair *) open CCPair module T = (val Containers_testlib.make ~__FILE__ ()) -include T +include T;; -(* Test basic construction and accessors *) t @@ fun () -> make 1 2 = (1, 2);; t @@ fun () -> fst (make 'a' 'b') = 'a';; t @@ fun () -> snd (make 'a' 'b') = 'b';; diff --git a/tests/core/t_ref.ml b/tests/core/t_ref.ml index 4f35a241..51d9f69c 100644 --- a/tests/core/t_ref.ml +++ b/tests/core/t_ref.ml @@ -1,9 +1,7 @@ -(* Tests for CCRef *) open CCRef module T = (val Containers_testlib.make ~__FILE__ ()) -include T +include T;; -(* Test create *) t @@ fun () -> let r = create 5 in !r = 5 diff --git a/tests/core/t_result.ml b/tests/core/t_result.ml index e16305c6..02ac33c2 100644 --- a/tests/core/t_result.ml +++ b/tests/core/t_result.ml @@ -322,3 +322,11 @@ q Q.(list (result int string)) (fun l -> | Ok values -> List.for_all (function Ok _ -> true | Error _ -> false) l && List.length values <= List.length l | Error _ -> List.exists (function Error _ -> true | Ok _ -> false) l );; + +(* Additional focused tests for high-value functions *) +t @@ fun () -> map (( + ) 1) (Ok 2) = Ok 3;; +t @@ fun () -> is_ok (Ok 1) && not (is_ok (Error "e"));; +t @@ fun () -> to_opt (Ok 5) = Some 5 && to_opt (Error "e") = None;; +t @@ fun () -> both (Ok 3) (Ok 5) = Ok (3, 5);; +q Q.int (fun x -> return x = Ok x);; +q Q.int (fun x -> to_opt (Ok x) = Some x);;