From 1b026f267c6efea4417783500cd590cf2ef5e62a Mon Sep 17 00:00:00 2001 From: Simon Cruanes Date: Sun, 19 Nov 2023 21:47:39 -0500 Subject: [PATCH] tests: update t_list to check more functions for tail-rec safety --- tests/core/t_list.ml | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/tests/core/t_list.ml b/tests/core/t_list.ml index 1de591f8..657e3aab 100644 --- a/tests/core/t_list.ml +++ b/tests/core/t_list.ml @@ -237,6 +237,11 @@ combine (1 -- 100_000) (1 -- 100_000) = List.combine (1 -- 100_000) (1 -- 100_000) ;; +t @@ fun () -> +combine (1 -- 300_000) (1 -- 300_000) += List.combine (1 -- 300_000) (1 -- 300_000) +;; + q Q.( let p = small_list int in @@ -741,6 +746,7 @@ t @@ fun () -> take_while (fun x -> x < 10) (1 -- 20) = 1 -- 9;; t @@ fun () -> take_while (fun x -> x <> 0) [ 0; 1; 2; 3 ] = [];; t @@ fun () -> take_while (fun _ -> true) [] = [];; t @@ fun () -> take_while (fun _ -> true) (1 -- 10) = 1 -- 10;; +t @@ fun () -> take_while (fun _ -> true) (1 -- 300_000) = 1 -- 300_000;; q Q.(pair (fun1 Observable.int bool) (list small_int)) @@ -761,6 +767,13 @@ q l1 = take_while (Q.Fn.apply f) l && l2 = drop_while (Q.Fn.apply f) l) ;; +t @@ fun () -> take_drop_while (fun _ -> true) [] = ([], []);; +t @@ fun () -> take_drop_while (fun _ -> true) (1 -- 10) = ([], 1 -- 10);; + +t @@ fun () -> +take_drop_while (fun _ -> true) (1 -- 300_000) = ([], 1 -- 300_000) +;; + eq ~printer:Q.Print.(option (list int)) (Some [ 2; 3 ]) (tail_opt [ 1; 2; 3 ]);; eq ~printer:Q.Print.(option (list int)) (Some []) (tail_opt [ 1 ]);; eq ~printer:Q.Print.(option (list int)) None (tail_opt []);; @@ -1046,6 +1059,8 @@ random_len 10 CCInt.random_small (Random.State.make [||]) |> List.length = 10 eq ~printer:(fun s -> s) (to_string string_of_int []) "";; eq ~printer:(fun s -> s) (to_string ~start:"[" ~stop:"]" string_of_int []) "[]" ;; +eq (1 -- 100) (of_seq (to_seq (1 -- 100)));; +eq (1 -- 100_000) (of_seq (to_seq (1 -- 100_000)));; eq ~printer:(fun s -> s) @@ -1067,6 +1082,8 @@ eq q Q.(list int) (fun l -> of_iter (to_iter l) = l);; q Q.(list int) (fun l -> of_gen (to_gen l) = l);; +eq (1 -- 100) (of_gen (to_gen (1 -- 100)));; +eq (1 -- 100_000) (of_gen (to_gen (1 -- 100_000)));; eq ~printer:(fun s -> s)