Handle list head and tail updates with explicit empty-list errors
This commit is contained in:
4 files changed
+26
No files matched your search
+10
@@ -30,3 +30,13 @@ let () =
|
||||
assert (set _id "grey" 9 = "grey");
|
||||
assert (view (compose _id _1) (9, false) = view _1 (9, false));
|
||||
assert (set (compose _2 _id) "grey" (true, 9) = set _2 "grey" (true, 9))
|
||||
|
||||
let () =
|
||||
assert (view _hd [1; 2] = 1);
|
||||
assert (view _tl [1] = []);
|
||||
assert (set _hd 3 [1; 2] = [3; 2]);
|
||||
assert (set _tl [3; 4] [1; 2] = [1; 3; 4]);
|
||||
List.iter (fun action ->
|
||||
try action (); assert false with Invalid_argument _ -> ())
|
||||
[(fun () -> ignore (view _hd [])); (fun () -> ignore (view _tl []));
|
||||
(fun () -> ignore (set _hd 1 [])); (fun () -> ignore (set _tl [] []))]
|
||||
Reference in new issue
Block a user