Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/weak/lin_tests.ml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ struct
[ val_ "Weak.length" Weak.length (t @-> returning int);
val_ "Weak.set" Weak.set (t @-> int @-> option int64 @-> returning_or_exc unit);
val_ "Weak.get" Weak.get (t @-> int @-> returning_or_exc (option int64));
val_ "Weak.get_copy" Weak.get_copy (t @-> int @-> returning_or_exc (option int64));
(* Weak.get_copy is considered dangerous and an alias for Weak.get since 5.6 https://github.com/ocaml/ocaml/pull/15064 *)
(*val_ "Weak.get_copy" Weak.get_copy (t @-> int @-> returning_or_exc (option int64)); *)
val_ "Weak.check" Weak.check (t @-> int @-> returning_or_exc bool);
val_ "Weak.fill" Weak.fill (t @-> int @-> int @-> option int64 @-> returning_or_exc unit);
(*val blit : 'a t -> int -> 'a t -> int -> int -> unit *)
Expand Down
17 changes: 9 additions & 8 deletions src/weak/stm_tests_weak_spec.ml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ type cmd =
| Length
| Set of int * data option
| Get of int
| Get_copy of int
(* Weak.get_copy is considered dangerous and an alias for Weak.get since 5.6 https://github.com/ocaml/ocaml/pull/15064 *)
(*| Get_copy of int *)
| Check of int
| Fill of int * int * data option
and data = string
Expand All @@ -18,7 +19,7 @@ let pp_cmd par fmt x =
| Length -> cst0 "Length" fmt
| Set (x, y) -> cst2 pp_int (pp_option pp_string) "Set" par fmt x y
| Get x -> cst1 pp_int "Get" par fmt x
| Get_copy x -> cst1 pp_int "Get_copy" par fmt x
(*| Get_copy x -> cst1 pp_int "Get_copy" par fmt x *)
| Check x -> cst1 pp_int "Check" par fmt x
| Fill (x, y, z) ->
cst3 pp_int pp_int (pp_option pp_string) "Fill" par fmt x y z
Expand All @@ -32,7 +33,7 @@ let _shrink_cmd c = match c with
| Length -> Iter.empty
| Set (i, d_opt) -> Iter.map (fun i -> Set (i,d_opt)) (Shrink.int i)
| Get i -> Iter.map (fun i -> Get i) (Shrink.int i)
| Get_copy i -> Iter.map (fun i -> Get_copy i) (Shrink.int i)
(*| Get_copy i -> Iter.map (fun i -> Get_copy i) (Shrink.int i) *)
| Check i -> Iter.map (fun i -> Check i) (Shrink.int i)
| Fill (i,j,d_opt) ->
Iter.(map (fun i -> Fill (i,j,d_opt)) (Shrink.int i)
Expand All @@ -47,7 +48,7 @@ let arb_cmd s =
[ 1,return Length;
1,map2 (fun i d_opt -> Set (i,d_opt)) int_gen (option data_gen);
2,map (fun i -> Get i) int_gen;
2,map (fun i -> Get_copy i) int_gen;
(*2,map (fun i -> Get_copy i) int_gen; *)
2,map (fun i -> Check i) int_gen;
2,map3 (fun i len d_opt -> Fill (i,len,d_opt)) int_gen int_gen (option data_gen); (* hack: reusing int_gen for length *)
])
Expand All @@ -61,7 +62,7 @@ let next_state c s = match c with
| Set (i,d_opt) ->
List.mapi (fun j d_opt' -> if i=j then d_opt else d_opt') s
| Get _ -> s
| Get_copy _ -> s
(*| Get_copy _ -> s *)
| Check _ -> s
| Fill (i,l,d_opt) ->
if i >= 0 && l >= 0 && i+l-1 < List.length s
Expand All @@ -78,7 +79,7 @@ let run c a = match c with
| Length -> Res (int, Weak.length a)
| Set (i,d_opt) -> Res (result unit exn, protect (fun () -> Weak.set a i d_opt) ())
| Get i -> Res (result (option string) exn, protect (fun () -> Weak.get a i) ())
| Get_copy i -> Res (result (option string) exn, protect (fun () -> Weak.get_copy a i) ())
(*| Get_copy i -> Res (result (option string) exn, protect (fun () -> Weak.get_copy a i) ()) *)
| Check i -> Res (result bool exn, protect (fun () -> Weak.check a i) ())
| Fill (i,l,d_opt) -> Res (result unit exn, protect (fun () -> Weak.fill a i l d_opt) ())

Expand All @@ -92,10 +93,10 @@ let postcond c (s:state) res = match c, res with
if i < 0 || i >= List.length s
then r = Error (Invalid_argument "Weak.get")
else r = Ok None || r = Ok (List.nth s i)
| Get_copy i, Res ((Result (Option String,Exn),_), r) ->
(*| Get_copy i, Res ((Result (Option String,Exn),_), r) ->
if i < 0 || i >= List.length s
then r = Error (Invalid_argument "Weak.get_copy")
else r = Ok None || r = Ok (List.nth s i)
else r = Ok None || r = Ok (List.nth s i) *)
| Check i, Res ((Result (Bool,Exn),_),r) ->
if i < 0 || i >= List.length s
then r = Error (Invalid_argument "Weak.check")
Expand Down
Loading