Skip to content

Commit c302f17

Browse files
committed
fix problems
1 parent 483d6be commit c302f17

File tree

1 file changed

+4
-37
lines changed

1 file changed

+4
-37
lines changed

src/sys/stm_tests.ml

Lines changed: 4 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ struct
88
| Mkdir of string list * string * int
99
| Rmdir of string list * string
1010
| Readdir of string list
11-
| Rename of string
1211
| Touch of string list * string * int
1312
[@@deriving show { with_path = false }]
1413

@@ -23,19 +22,19 @@ struct
2322
type sut = unit
2423

2524
let (/) = Filename.concat
25+
26+
let update_map_name map_name k v = Map_names.add k v (Map_names.remove k map_name)
2627

2728
let arb_cmd _s =
2829
let name_gen = Gen.(oneofl ["aaa" ; "bbb" ; "ccc" ; "ddd" ; "eee"]) in
29-
(* ameliorer ca avec d'autre caracteres, *)
30-
(* let name_gen = Gen.small_string in *)
3130
let path_gen = Gen.map (fun path -> path) (Gen.list_size (Gen.int_bound 5) name_gen) in (* can be empty *)
3231
let perm_gen = Gen.(oneofl [0o777]) in
3332
QCheck.make ~print:show_cmd
3433
Gen.(oneof
3534
[
3635
map (fun path -> File_exists (path)) path_gen ;
3736
map3 (fun path new_dir_name perm -> Mkdir (path, new_dir_name, perm)) path_gen name_gen perm_gen;
38-
map2 (fun path delete_dir_name -> Rmdir (path, delete_dir_name)) path_gen name_gen;
37+
map2 (fun path delete_dir_name -> Rmdir (path, delete_dir_name)) path_gen name_gen;
3938
map (fun path -> Readdir (path)) path_gen;
4039
map3 (fun path new_file_name perm -> Touch (path, new_file_name, perm)) path_gen name_gen perm_gen;
4140
])
@@ -44,8 +43,6 @@ struct
4443

4544
let init_state = Directory {perm = 0o777; fs_map = Map_names.empty}
4645

47-
let update_map_name map_name k v = Map_names.add k v (Map_names.remove k map_name)
48-
4946
let rec find_opt fs path =
5047
match fs with
5148
| File f ->
@@ -113,36 +110,6 @@ struct
113110
else
114111
Directory {d with fs_map = (update_map_name d.fs_map next_in_path nfs)}))
115112

116-
let rec rename fs o_path old_name n_path new_name =
117-
match fs with
118-
| File _ -> fs
119-
| Directory d ->
120-
(match o_path, n_path with
121-
| [], [] ->
122-
(match Map_names.find_opt old_name d.fs_map with
123-
| None -> Directory d
124-
| Some tmp_fs ->
125-
let new_map = Map_names.add new_name tmp_fs d.fs_map in
126-
let new_map = Map_names.remove old_name new_map in
127-
Directory {d with fs_map = new_map})
128-
| o_next_in_path :: o_tl_path, n_next_in_path :: n_tl_path ->
129-
if not (o_next_in_path = n_next_in_path)
130-
then fs
131-
else
132-
(match Map_names.find_opt o_next_in_path d.fs_map with
133-
| None -> fs
134-
| Some sub_fs ->
135-
let nfs = rename sub_fs o_tl_path old_name n_tl_path new_name in
136-
if nfs = sub_fs
137-
then fs
138-
else
139-
let new_map = Map_names.remove o_next_in_path d.fs_map in
140-
let new_map = Map_names.add o_next_in_path nfs new_map in
141-
Directory {d with fs_map = new_map})
142-
| _ , _ -> fs)
143-
| _ -> fs
144-
145-
146113
let rec touch fs path new_file_name perm =
147114
match fs with
148115
| File _ -> fs
@@ -189,7 +156,7 @@ struct
189156
match c with
190157
| File_exists (path) -> Res (bool, Sys.file_exists (p path))
191158
| Mkdir (path, new_dir_name, perm) ->
192-
Res (result unit exn, protect (Sys.mkdir ((p path) / new_dir_name))perm)
159+
Res (result unit exn, protect (Sys.mkdir ((p path) / new_dir_name)) perm)
193160
| Rmdir (path, delete_dir_name) ->
194161
Res (result unit exn, protect (Sys.rmdir) ((p path) / delete_dir_name))
195162
| Readdir (path) ->

0 commit comments

Comments
 (0)