diff options
author | Son Ho | 2024-04-11 20:31:16 +0200 |
---|---|---|
committer | Son Ho | 2024-04-11 20:31:16 +0200 |
commit | b6421bc01df278f625a8c95b4ea36ad2e4355718 (patch) | |
tree | 6246ef2b038560e3deae41e4fa700f14390cd14f /tests/fstar/hashmap_on_disk/HashmapMain.Funs.fst | |
parent | 44065f447dc3a2f4b1441b97b9687d1c1b85afbf (diff) | |
parent | 2f8aa9b47acb5c98aed91c29b04f71099452e781 (diff) |
Merge branch 'son/clean' into checked-ops
Diffstat (limited to 'tests/fstar/hashmap_on_disk/HashmapMain.Funs.fst')
-rw-r--r-- | tests/fstar/hashmap_on_disk/HashmapMain.Funs.fst | 83 |
1 files changed, 38 insertions, 45 deletions
diff --git a/tests/fstar/hashmap_on_disk/HashmapMain.Funs.fst b/tests/fstar/hashmap_on_disk/HashmapMain.Funs.fst index 97f4151f..ff86e087 100644 --- a/tests/fstar/hashmap_on_disk/HashmapMain.Funs.fst +++ b/tests/fstar/hashmap_on_disk/HashmapMain.Funs.fst @@ -11,7 +11,7 @@ include HashmapMain.Clauses (** [hashmap_main::hashmap::hash_key]: Source: 'src/hashmap.rs', lines 27:0-27:32 *) let hashmap_hash_key (k : usize) : result usize = - Return k + Ok k (** [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap<T>}::allocate_slots]: loop 0: Source: 'src/hashmap.rs', lines 50:4-56:5 *) @@ -26,7 +26,7 @@ let rec hashmap_HashMap_allocate_slots_loop in let* n1 = usize_sub n 1 in hashmap_HashMap_allocate_slots_loop t slots1 n1 - else Return slots + else Ok slots (** [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap<T>}::allocate_slots]: Source: 'src/hashmap.rs', lines 50:4-50:76 *) @@ -48,7 +48,7 @@ let hashmap_HashMap_new_with_capacity capacity in let* i = usize_mul capacity max_load_dividend in let* i1 = usize_div i max_load_divisor in - Return + Ok { num_entries = 0; max_load_factor = (max_load_dividend, max_load_divisor); @@ -78,20 +78,20 @@ let rec hashmap_HashMap_clear_loop let* i2 = usize_add i 1 in let* slots1 = index_mut_back Hashmap_List_Nil in hashmap_HashMap_clear_loop t slots1 i2 - else Return slots + else Ok slots (** [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap<T>}::clear]: Source: 'src/hashmap.rs', lines 80:4-80:27 *) let hashmap_HashMap_clear (t : Type0) (self : hashmap_HashMap_t t) : result (hashmap_HashMap_t t) = - let* back = hashmap_HashMap_clear_loop t self.slots 0 in - Return { self with num_entries = 0; slots = back } + let* hm = hashmap_HashMap_clear_loop t self.slots 0 in + Ok { self with num_entries = 0; slots = hm } (** [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap<T>}::len]: Source: 'src/hashmap.rs', lines 90:4-90:30 *) let hashmap_HashMap_len (t : Type0) (self : hashmap_HashMap_t t) : result usize = - Return self.num_entries + Ok self.num_entries (** [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap<T>}::insert_in_list]: loop 0: Source: 'src/hashmap.rs', lines 97:4-114:5 *) @@ -103,12 +103,11 @@ let rec hashmap_HashMap_insert_in_list_loop begin match ls with | Hashmap_List_Cons ckey cvalue tl -> if ckey = key - then Return (false, Hashmap_List_Cons ckey value tl) + then Ok (false, Hashmap_List_Cons ckey value tl) else - let* (b, back) = hashmap_HashMap_insert_in_list_loop t key value tl in - Return (b, Hashmap_List_Cons ckey cvalue back) - | Hashmap_List_Nil -> - Return (true, Hashmap_List_Cons key value Hashmap_List_Nil) + let* (b, tl1) = hashmap_HashMap_insert_in_list_loop t key value tl in + Ok (b, Hashmap_List_Cons ckey cvalue tl1) + | Hashmap_List_Nil -> Ok (true, Hashmap_List_Cons key value Hashmap_List_Nil) end (** [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap<T>}::insert_in_list]: @@ -137,8 +136,8 @@ let hashmap_HashMap_insert_no_resize then let* i1 = usize_add self.num_entries 1 in let* v = index_mut_back l1 in - Return { self with num_entries = i1; slots = v } - else let* v = index_mut_back l1 in Return { self with slots = v } + Ok { self with num_entries = i1; slots = v } + else let* v = index_mut_back l1 in Ok { self with slots = v } (** [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap<T>}::move_elements_from_list]: loop 0: Source: 'src/hashmap.rs', lines 183:4-196:5 *) @@ -152,7 +151,7 @@ let rec hashmap_HashMap_move_elements_from_list_loop | Hashmap_List_Cons k v tl -> let* ntable1 = hashmap_HashMap_insert_no_resize t ntable k v in hashmap_HashMap_move_elements_from_list_loop t ntable1 tl - | Hashmap_List_Nil -> Return ntable + | Hashmap_List_Nil -> Ok ntable end (** [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap<T>}::move_elements_from_list]: @@ -183,7 +182,7 @@ let rec hashmap_HashMap_move_elements_loop let* i2 = usize_add i 1 in let* slots1 = index_mut_back l1 in hashmap_HashMap_move_elements_loop t ntable1 slots1 i2 - else Return (ntable, slots) + else Ok (ntable, slots) (** [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap<T>}::move_elements]: Source: 'src/hashmap.rs', lines 171:4-171:95 *) @@ -209,10 +208,10 @@ let hashmap_HashMap_try_resize let* ntable = hashmap_HashMap_new_with_capacity t i3 i i1 in let* p = hashmap_HashMap_move_elements t ntable self.slots 0 in let (ntable1, _) = p in - Return + Ok { ntable1 with num_entries = self.num_entries; max_load_factor = (i, i1) } - else Return { self with max_load_factor = (i, i1) } + else Ok { self with max_load_factor = (i, i1) } (** [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap<T>}::insert]: Source: 'src/hashmap.rs', lines 129:4-129:48 *) @@ -222,9 +221,7 @@ let hashmap_HashMap_insert = let* self1 = hashmap_HashMap_insert_no_resize t self key value in let* i = hashmap_HashMap_len t self1 in - if i > self1.max_load - then hashmap_HashMap_try_resize t self1 - else Return self1 + if i > self1.max_load then hashmap_HashMap_try_resize t self1 else Ok self1 (** [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap<T>}::contains_key_in_list]: loop 0: Source: 'src/hashmap.rs', lines 206:4-219:5 *) @@ -236,9 +233,9 @@ let rec hashmap_HashMap_contains_key_in_list_loop begin match ls with | Hashmap_List_Cons ckey _ tl -> if ckey = key - then Return true + then Ok true else hashmap_HashMap_contains_key_in_list_loop t key tl - | Hashmap_List_Nil -> Return false + | Hashmap_List_Nil -> Ok false end (** [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap<T>}::contains_key_in_list]: @@ -269,9 +266,7 @@ let rec hashmap_HashMap_get_in_list_loop = begin match ls with | Hashmap_List_Cons ckey cvalue tl -> - if ckey = key - then Return cvalue - else hashmap_HashMap_get_in_list_loop t key tl + if ckey = key then Ok cvalue else hashmap_HashMap_get_in_list_loop t key tl | Hashmap_List_Nil -> Fail Failure end @@ -305,15 +300,14 @@ let rec hashmap_HashMap_get_mut_in_list_loop | Hashmap_List_Cons ckey cvalue tl -> if ckey = key then - let back_'a = fun ret -> Return (Hashmap_List_Cons ckey ret tl) in - Return (cvalue, back_'a) + let back = fun ret -> Ok (Hashmap_List_Cons ckey ret tl) in + Ok (cvalue, back) else - let* (x, back_'a) = hashmap_HashMap_get_mut_in_list_loop t tl key in - let back_'a1 = + let* (x, back) = hashmap_HashMap_get_mut_in_list_loop t tl key in + let back1 = fun ret -> - let* tl1 = back_'a ret in Return (Hashmap_List_Cons ckey cvalue tl1) - in - Return (x, back_'a1) + let* tl1 = back ret in Ok (Hashmap_List_Cons ckey cvalue tl1) in + Ok (x, back1) | Hashmap_List_Nil -> Fail Failure end @@ -339,12 +333,12 @@ let hashmap_HashMap_get_mut (core_slice_index_SliceIndexUsizeSliceTInst (hashmap_List_t t)) self.slots hash_mod in let* (x, get_mut_in_list_back) = hashmap_HashMap_get_mut_in_list t l key in - let back_'a = + let back = fun ret -> let* l1 = get_mut_in_list_back ret in let* v = index_mut_back l1 in - Return { self with slots = v } in - Return (x, back_'a) + Ok { self with slots = v } in + Ok (x, back) (** [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap<T>}::remove_from_list]: loop 0: Source: 'src/hashmap.rs', lines 265:4-291:5 *) @@ -361,13 +355,13 @@ let rec hashmap_HashMap_remove_from_list_loop core_mem_replace (hashmap_List_t t) (Hashmap_List_Cons ckey x tl) Hashmap_List_Nil in begin match mv_ls with - | Hashmap_List_Cons _ cvalue tl1 -> Return (Some cvalue, tl1) + | Hashmap_List_Cons _ cvalue tl1 -> Ok (Some cvalue, tl1) | Hashmap_List_Nil -> Fail Failure end else - let* (o, back) = hashmap_HashMap_remove_from_list_loop t key tl in - Return (o, Hashmap_List_Cons ckey x back) - | Hashmap_List_Nil -> Return (None, Hashmap_List_Nil) + let* (o, tl1) = hashmap_HashMap_remove_from_list_loop t key tl in + Ok (o, Hashmap_List_Cons ckey x tl1) + | Hashmap_List_Nil -> Ok (None, Hashmap_List_Nil) end (** [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap<T>}::remove_from_list]: @@ -393,12 +387,11 @@ let hashmap_HashMap_remove self.slots hash_mod in let* (x, l1) = hashmap_HashMap_remove_from_list t key l in begin match x with - | None -> - let* v = index_mut_back l1 in Return (None, { self with slots = v }) + | None -> let* v = index_mut_back l1 in Ok (None, { self with slots = v }) | Some x1 -> let* i1 = usize_sub self.num_entries 1 in let* v = index_mut_back l1 in - Return (Some x1, { self with num_entries = i1; slots = v }) + Ok (Some x1, { self with num_entries = i1; slots = v }) end (** [hashmap_main::hashmap::test1]: @@ -435,7 +428,7 @@ let hashmap_test1 : result unit = then Fail Failure else let* i4 = hashmap_HashMap_get u64 hm6 1056 in - if not (i4 = 256) then Fail Failure else Return () + if not (i4 = 256) then Fail Failure else Ok () end (** [hashmap_main::insert_on_disk]: @@ -449,5 +442,5 @@ let insert_on_disk (** [hashmap_main::main]: Source: 'src/hashmap_main.rs', lines 16:0-16:13 *) let main : result unit = - Return () + Ok () |