Skip to content

Commit 8d102ec

Browse files
committed
Define fix_cmd for all existing Lin tests
1 parent 4e3dcdf commit 8d102ec

File tree

9 files changed

+90
-1
lines changed

9 files changed

+90
-1
lines changed

lib/lin.ml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,9 @@ module Make(Spec : CmdSpec)
341341
[(3,Gen.return (None,SchedYield));
342342
(5,Gen.map (fun (opt,c) -> (opt,UserCmd c)) (Spec.gen_cmd env))])
343343

344-
let fix_cmd _ = Iter.return
344+
let fix_cmd env = function
345+
| SchedYield -> Iter.return SchedYield
346+
| UserCmd cmd -> Iter.map (fun c -> UserCmd c) (Spec.fix_cmd env cmd)
345347

346348
let shrink_cmd c = match c with
347349
| SchedYield -> Iter.empty

src/array/lin_tests.ml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,19 @@ struct
5858
| Sort v -> Iter.map (fun v -> Sort v) (Var.shrink v)
5959
| To_seq v -> Iter.map (fun v -> To_seq v) (Var.shrink v)
6060

61+
let fix_cmd env = function
62+
| Length i -> Iter.map (fun i -> Length i ) (Env.valid_states env i)
63+
| Get (i,x) -> Iter.map (fun i -> Get (i,x) ) (Env.valid_states env i)
64+
| Set (i,x,z) -> Iter.map (fun i -> Set (i,x,z) ) (Env.valid_states env i)
65+
| Sub (i,x,y) -> Iter.map (fun i -> Sub (i,x,y) ) (Env.valid_states env i)
66+
| Copy i -> Iter.map (fun i -> Copy i ) (Env.valid_states env i)
67+
| Fill (i,x,y,z) -> Iter.map (fun i -> Fill (i,x,y,z)) (Env.valid_states env i)
68+
| To_list i -> Iter.map (fun i -> To_list i ) (Env.valid_states env i)
69+
| Mem (i,z) -> Iter.map (fun i -> Mem (i,z) ) (Env.valid_states env i)
70+
| Sort i -> Iter.map (fun i -> Sort i ) (Env.valid_states env i)
71+
| To_seq i -> Iter.map (fun i -> To_seq i ) (Env.valid_states env i)
72+
| Append (i,j) -> Iter.(map (fun i j -> Append (i,j)) (Env.valid_states env i) <*> (Env.valid_states env j))
73+
6174
open Util
6275
(*let pp_exn = Util.pp_exn*)
6376
let pp fmt t = Format.fprintf fmt "%s" (QCheck.Print.(array char) t)

src/atomic/lin_tests.ml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,16 @@ struct
3232

3333
let shrink_cmd = Shrink.nil
3434

35+
let fix_cmd env = function
36+
| Make x as cmd -> Iter.return cmd
37+
| Get i -> Iter.map (fun i -> Get i ) (Env.valid_states env i)
38+
| Set (i,x) -> Iter.map (fun i -> Set (i,x) ) (Env.valid_states env i)
39+
| Exchange (i,x) -> Iter.map (fun i -> Exchange (i,x) ) (Env.valid_states env i)
40+
| Compare_and_set (i,x,y) -> Iter.map (fun i -> Compare_and_set (i,x,y)) (Env.valid_states env i)
41+
| Fetch_and_add (i,x) -> Iter.map (fun i -> Fetch_and_add (i,x) ) (Env.valid_states env i)
42+
| Incr i -> Iter.map (fun i -> Incr i ) (Env.valid_states env i)
43+
| Decr i -> Iter.map (fun i -> Decr i ) (Env.valid_states env i)
44+
3545
type res =
3646
| RMake of unit
3747
| RGet of int

src/hashtbl/lin_tests.ml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,18 @@ struct
5353
| Mem (v,c) -> Iter.map (fun c -> Mem (v,c)) (Shrink.char c)
5454
| Length _ -> Iter.empty
5555

56+
let fix_cmd env = function
57+
| Clear i -> Iter.map (fun i -> Clear i ) (Env.valid_states env i)
58+
| Copy i -> Iter.map (fun i -> Copy i ) (Env.valid_states env i)
59+
| Add (i,x,y) -> Iter.map (fun i -> Add (i,x,y) ) (Env.valid_states env i)
60+
| Remove (i,x) -> Iter.map (fun i -> Remove (i,x) ) (Env.valid_states env i)
61+
| Find (i,x) -> Iter.map (fun i -> Find (i,x) ) (Env.valid_states env i)
62+
| Find_opt (i,x) -> Iter.map (fun i -> Find_opt (i,x) ) (Env.valid_states env i)
63+
| Find_all (i,x) -> Iter.map (fun i -> Find_all (i,x) ) (Env.valid_states env i)
64+
| Replace (i,x,y) -> Iter.map (fun i -> Replace (i,x,y)) (Env.valid_states env i)
65+
| Mem (i,x) -> Iter.map (fun i -> Mem (i,x) ) (Env.valid_states env i)
66+
| Length i -> Iter.map (fun i -> Length i ) (Env.valid_states env i)
67+
5668
type res =
5769
| RClear
5870
| RCopy

src/internal/cleanup.ml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,11 @@ struct
2424

2525
let shrink_cmd = Shrink.nil
2626

27+
let fix_cmd env = function
28+
| Get i -> Iter.map (fun i -> Get i ) (Lin.Env.valid_states env i)
29+
| Set (i,x) -> Iter.map (fun i -> Set (i,x)) (Lin.Env.valid_states env i)
30+
| Add (i,x) -> Iter.map (fun i -> Add (i,x)) (Lin.Env.valid_states env i)
31+
2732
let init () = (ref Inited, ref 0)
2833

2934
let cleanup (status,_) =

src/lazy/lin_tests.ml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,13 @@ struct
6262
(* the Lazy tests already take a while to run - so better avoid spending extra time shrinking *)
6363
let shrink_cmd = Shrink.nil
6464

65+
let fix_cmd env = function
66+
| Force i -> Iter.map (fun i -> Force i ) (Env.valid_states env i)
67+
| Force_val i -> Iter.map (fun i -> Force_val i ) (Env.valid_states env i)
68+
| Is_val i -> Iter.map (fun i -> Is_val i ) (Env.valid_states env i)
69+
| Map (i,f) -> Iter.map (fun i -> Map (i,f) ) (Env.valid_states env i)
70+
| Map_val (i,f) -> Iter.map (fun i -> Map_val (i,f)) (Env.valid_states env i)
71+
6572
type t = int Lazy.t
6673

6774
let cleanup _ = ()

src/neg_tests/lin_tests_common.ml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,13 @@ module RConf_int = struct
5252
| Set (t,i) -> Iter.map (fun i -> Set (t,i)) (Shrink.int i)
5353
| Add (t,i) -> Iter.map (fun i -> Add (t,i)) (Shrink.int i)
5454

55+
let fix_cmd env = function
56+
| Get i -> Iter.map (fun i -> Get i ) (Env.valid_states env i)
57+
| Set (i,x) -> Iter.map (fun i -> Set (i,x)) (Env.valid_states env i)
58+
| Add (i,x) -> Iter.map (fun i -> Add (i,x)) (Env.valid_states env i)
59+
| Incr i -> Iter.map (fun i -> Incr i ) (Env.valid_states env i)
60+
| Decr i -> Iter.map (fun i -> Decr i ) (Env.valid_states env i)
61+
5562
type res = RGet of int | RSet | RAdd | RIncr | RDecr [@@deriving show { with_path = false }, eq]
5663

5764
let init () = Sut_int.init ()
@@ -97,6 +104,13 @@ module RConf_int64 = struct
97104
| Set (t,i) -> Iter.map (fun i -> Set (t,i)) (Shrink.int64 i)
98105
| Add (t,i) -> Iter.map (fun i -> Add (t,i)) (Shrink.int64 i)
99106

107+
let fix_cmd env = function
108+
| Get i -> Iter.map (fun i -> Get i ) (Env.valid_states env i)
109+
| Set (i,x) -> Iter.map (fun i -> Set (i,x)) (Env.valid_states env i)
110+
| Add (i,x) -> Iter.map (fun i -> Add (i,x)) (Env.valid_states env i)
111+
| Incr i -> Iter.map (fun i -> Incr i ) (Env.valid_states env i)
112+
| Decr i -> Iter.map (fun i -> Decr i ) (Env.valid_states env i)
113+
100114
type res = RGet of int64 | RSet | RAdd | RIncr | RDecr [@@deriving show { with_path = false }, eq]
101115

102116
let init () = Sut_int64.init ()
@@ -146,6 +160,10 @@ struct
146160
| Add_node (t,i) -> Iter.map (fun i -> Add_node (t,i)) (T.shrink i)
147161
| Member (t,i) -> Iter.map (fun i -> Member (t,i)) (T.shrink i)
148162

163+
let fix_cmd env = function
164+
| Add_node (i,x) -> Iter.map (fun i -> Add_node (i,x)) (Lin.Env.valid_states env i)
165+
| Member (i,x) -> Iter.map (fun i -> Member (i,x) ) (Lin.Env.valid_states env i)
166+
149167
type res = RAdd_node of bool | RMember of bool [@@deriving show { with_path = false }, eq]
150168

151169
let init () = CList.list_init T.zero

src/queue/lin_tests.ml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,17 @@ module Spec =
4747
<+>
4848
(map (fun i -> Fold (t,f,i)) (Shrink.int i)))
4949

50+
let fix_cmd env = function
51+
| Add (i,x) -> Iter.map (fun i -> Add (i,x) ) (Env.valid_states env i)
52+
| Take i -> Iter.map (fun i -> Take i ) (Env.valid_states env i)
53+
| Take_opt i -> Iter.map (fun i -> Take_opt i ) (Env.valid_states env i)
54+
| Peek i -> Iter.map (fun i -> Peek i ) (Env.valid_states env i)
55+
| Peek_opt i -> Iter.map (fun i -> Peek_opt i ) (Env.valid_states env i)
56+
| Clear i -> Iter.map (fun i -> Clear i ) (Env.valid_states env i)
57+
| Is_empty i -> Iter.map (fun i -> Is_empty i ) (Env.valid_states env i)
58+
| Fold (i,x,y) -> Iter.map (fun i -> Fold (i,x,y)) (Env.valid_states env i)
59+
| Length i -> Iter.map (fun i -> Length i ) (Env.valid_states env i)
60+
5061
type res =
5162
| RAdd
5263
| RTake of ((int, exn) result [@equal (=)])

src/stack/lin_tests.ml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,17 @@ module Spec =
4848
<+>
4949
(map (fun i -> Fold (t,f,i)) (Shrink.int i)))
5050

51+
let fix_cmd env = function
52+
| Push (i,x) -> Iter.map (fun i -> Push (i,x) ) (Env.valid_states env i)
53+
| Pop i -> Iter.map (fun i -> Pop i ) (Env.valid_states env i)
54+
| Pop_opt i -> Iter.map (fun i -> Pop_opt i ) (Env.valid_states env i)
55+
| Top i -> Iter.map (fun i -> Top i ) (Env.valid_states env i)
56+
| Top_opt i -> Iter.map (fun i -> Top_opt i ) (Env.valid_states env i)
57+
| Clear i -> Iter.map (fun i -> Clear i ) (Env.valid_states env i)
58+
| Is_empty i -> Iter.map (fun i -> Is_empty i ) (Env.valid_states env i)
59+
| Fold (i,f,x) -> Iter.map (fun i -> Fold (i,f,x)) (Env.valid_states env i)
60+
| Length i -> Iter.map (fun i -> Length i ) (Env.valid_states env i)
61+
5162
type res =
5263
| RPush
5364
| RPop of ((int, exn) result [@equal (=)])

0 commit comments

Comments
 (0)