mirror of
https://github.com/c-cube/ocaml-containers.git
synced 2026-03-13 00:36:17 -04:00
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
This commit is contained in:
parent
391e709fff
commit
f6f088b1b9
6 changed files with 16 additions and 27 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
);;
|
||||
|
||||
|
|
|
|||
|
|
@ -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 *)
|
||||
|
||||
|
|
|
|||
|
|
@ -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';;
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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);;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue