summaryrefslogtreecommitdiff
path: root/tests/fstar/betree
diff options
context:
space:
mode:
authorSon Ho2023-02-05 22:03:41 +0100
committerSon HO2023-06-04 21:44:33 +0200
commitc6913b8bf90689d8961c47f59896443e7fae164d (patch)
tree3a2b61a3df49fef14c8ad558ff9630014a5c07e1 /tests/fstar/betree
parent9ec68c058a1829166fbb2511dedfbe0c2f94d6bc (diff)
Make sure let-bindings in Lean end with line breaks and improve formatting
Diffstat (limited to 'tests/fstar/betree')
-rw-r--r--tests/fstar/betree/BetreeMain.Funs.fst121
1 files changed, 61 insertions, 60 deletions
diff --git a/tests/fstar/betree/BetreeMain.Funs.fst b/tests/fstar/betree/BetreeMain.Funs.fst
index 8c0c1cc1..f3a01884 100644
--- a/tests/fstar/betree/BetreeMain.Funs.fst
+++ b/tests/fstar/betree/BetreeMain.Funs.fst
@@ -41,7 +41,8 @@ let betree_fresh_node_id_fwd (counter : u64) : result u64 =
let* _ = u64_add counter 1 in Return counter
(** [betree_main::betree::fresh_node_id] *)
-let betree_fresh_node_id_back (counter : u64) : result u64 = u64_add counter 1
+let betree_fresh_node_id_back (counter : u64) : result u64 =
+ u64_add counter 1
(** [betree_main::betree::NodeIdCounter::{0}::new] *)
let betree_node_id_counter_new_fwd : result betree_node_id_counter_t =
@@ -161,11 +162,11 @@ let rec betree_list_partition_at_pivot_fwd
let (i, x) = hd in
if i >= pivot
then Return (BetreeListNil, BetreeListCons (i, x) tl)
- else begin
+ else
let* p = betree_list_partition_at_pivot_fwd t tl pivot in
let (ls0, ls1) = p in
let l = ls0 in
- Return (BetreeListCons (i, x) l, ls1) end
+ Return (BetreeListCons (i, x) l, ls1)
| BetreeListNil -> Return (BetreeListNil, BetreeListNil)
end
@@ -257,10 +258,10 @@ let rec betree_node_lookup_first_message_for_key_back
let (i, m) = x in
if i >= key
then Return ret
- else begin
+ else
let* next_msgs0 =
betree_node_lookup_first_message_for_key_back key next_msgs ret in
- Return (BetreeListCons (i, m) next_msgs0) end
+ Return (BetreeListCons (i, m) next_msgs0)
| BetreeListNil -> Return ret
end
@@ -273,7 +274,7 @@ let rec betree_node_apply_upserts_fwd
=
let* b = betree_list_head_has_key_fwd betree_message_t msgs key in
if b
- then begin
+ then
let* msg = betree_list_pop_front_fwd (u64 & betree_message_t) msgs in
let (_, m) = msg in
begin match m with
@@ -283,13 +284,13 @@ let rec betree_node_apply_upserts_fwd
let* v = betree_upsert_update_fwd prev s in
let* msgs0 = betree_list_pop_front_back (u64 & betree_message_t) msgs in
betree_node_apply_upserts_fwd msgs0 (Some v) key st
- end end
- else begin
+ end
+ else
let* (st0, v) = core_option_option_unwrap_fwd u64 prev st in
let* _ =
betree_list_push_front_fwd_back (u64 & betree_message_t) msgs (key,
BetreeMessageInsert v) in
- Return (st0, v) end
+ Return (st0, v)
(** [betree_main::betree::Node::{5}::apply_upserts] *)
let rec betree_node_apply_upserts_back
@@ -300,7 +301,7 @@ let rec betree_node_apply_upserts_back
=
let* b = betree_list_head_has_key_fwd betree_message_t msgs key in
if b
- then begin
+ then
let* msg = betree_list_pop_front_fwd (u64 & betree_message_t) msgs in
let (_, m) = msg in
begin match m with
@@ -310,11 +311,11 @@ let rec betree_node_apply_upserts_back
let* v = betree_upsert_update_fwd prev s in
let* msgs0 = betree_list_pop_front_back (u64 & betree_message_t) msgs in
betree_node_apply_upserts_back msgs0 (Some v) key st
- end end
- else begin
+ end
+ else
let* (_, v) = core_option_option_unwrap_fwd u64 prev st in
betree_list_push_front_fwd_back (u64 & betree_message_t) msgs (key,
- BetreeMessageInsert v) end
+ BetreeMessageInsert v)
(** [betree_main::betree::Node::{5}::lookup] *)
let rec betree_node_lookup_fwd
@@ -331,13 +332,13 @@ let rec betree_node_lookup_fwd
| BetreeListCons p l ->
let (k, msg) = p in
if k <> key
- then begin
+ then
let* (st1, opt) = betree_internal_lookup_in_children_fwd node key st0
in
let* _ =
betree_node_lookup_first_message_for_key_back key msgs
(BetreeListCons (k, msg) l) in
- Return (st1, opt) end
+ Return (st1, opt)
else
begin match msg with
| BetreeMessageInsert v ->
@@ -394,12 +395,12 @@ and betree_node_lookup_back
| BetreeListCons p l ->
let (k, msg) = p in
if k <> key
- then begin
+ then
let* _ =
betree_node_lookup_first_message_for_key_back key msgs
(BetreeListCons (k, msg) l) in
let* node0 = betree_internal_lookup_in_children_back node key st0 in
- Return (BetreeNodeInternal node0) end
+ Return (BetreeNodeInternal node0)
else
begin match msg with
| BetreeMessageInsert v ->
@@ -458,14 +459,14 @@ and betree_internal_lookup_in_children_back
(decreases (betree_internal_lookup_in_children_decreases self key st))
=
if key < self.betree_internal_pivot
- then begin
+ then
let* n = betree_node_lookup_back self.betree_internal_left key st in
Return (Mkbetree_internal_t self.betree_internal_id
- self.betree_internal_pivot n self.betree_internal_right) end
- else begin
+ self.betree_internal_pivot n self.betree_internal_right)
+ else
let* n = betree_node_lookup_back self.betree_internal_right key st in
Return (Mkbetree_internal_t self.betree_internal_id
- self.betree_internal_pivot self.betree_internal_left n) end
+ self.betree_internal_pivot self.betree_internal_left n)
(** [betree_main::betree::Node::{5}::lookup_mut_in_bindings] *)
let rec betree_node_lookup_mut_in_bindings_fwd
@@ -494,9 +495,9 @@ let rec betree_node_lookup_mut_in_bindings_back
let (i, i0) = hd in
if i >= key
then Return ret
- else begin
+ else
let* tl0 = betree_node_lookup_mut_in_bindings_back key tl ret in
- Return (BetreeListCons (i, i0) tl0) end
+ Return (BetreeListCons (i, i0) tl0)
| BetreeListNil -> Return ret
end
@@ -509,7 +510,7 @@ let betree_node_apply_to_leaf_fwd_back
let* bindings0 = betree_node_lookup_mut_in_bindings_fwd key bindings in
let* b = betree_list_head_has_key_fwd u64 bindings0 key in
if b
- then begin
+ then
let* hd = betree_list_pop_front_fwd (u64 & u64) bindings0 in
begin match new_msg with
| BetreeMessageInsert v ->
@@ -527,7 +528,7 @@ let betree_node_apply_to_leaf_fwd_back
let* bindings2 =
betree_list_push_front_fwd_back (u64 & u64) bindings1 (key, v) in
betree_node_lookup_mut_in_bindings_back key bindings bindings2
- end end
+ end
else
begin match new_msg with
| BetreeMessageInsert v ->
@@ -568,11 +569,11 @@ let rec betree_node_filter_messages_for_key_fwd_back
| BetreeListCons p l ->
let (k, m) = p in
if k = key
- then begin
+ then
let* msgs0 =
betree_list_pop_front_back (u64 & betree_message_t) (BetreeListCons (k,
m) l) in
- betree_node_filter_messages_for_key_fwd_back key msgs0 end
+ betree_node_filter_messages_for_key_fwd_back key msgs0
else Return (BetreeListCons (k, m) l)
| BetreeListNil -> Return BetreeListNil
end
@@ -603,10 +604,10 @@ let rec betree_node_lookup_first_message_after_key_back
| BetreeListCons p next_msgs ->
let (k, m) = p in
if k = key
- then begin
+ then
let* next_msgs0 =
betree_node_lookup_first_message_after_key_back key next_msgs ret in
- Return (BetreeListCons (k, m) next_msgs0) end
+ Return (BetreeListCons (k, m) next_msgs0)
else Return ret
| BetreeListNil -> Return ret
end
@@ -665,11 +666,11 @@ let betree_node_apply_to_internal_fwd_back
betree_node_lookup_first_message_for_key_back key msgs msgs3
end
end
- else begin
+ else
let* msgs1 =
betree_list_push_front_fwd_back (u64 & betree_message_t) msgs0 (key,
new_msg) in
- betree_node_lookup_first_message_for_key_back key msgs msgs1 end
+ betree_node_lookup_first_message_for_key_back key msgs msgs1
(** [betree_main::betree::Node::{5}::apply_messages_to_internal] *)
let rec betree_node_apply_messages_to_internal_fwd_back
@@ -703,34 +704,34 @@ let rec betree_node_apply_messages_fwd
betree_node_apply_messages_to_internal_fwd_back content msgs in
let* num_msgs = betree_list_len_fwd (u64 & betree_message_t) content0 in
if num_msgs >= params.betree_params_min_flush_size
- then begin
+ then
let* (st1, content1) =
betree_internal_flush_fwd node params node_id_cnt content0 st0 in
let* (node0, _) =
betree_internal_flush_back node params node_id_cnt content0 st0 in
let* (st2, _) =
betree_store_internal_node_fwd node0.betree_internal_id content1 st1 in
- Return (st2, ()) end
- else begin
+ Return (st2, ())
+ else
let* (st1, _) =
betree_store_internal_node_fwd node.betree_internal_id content0 st0 in
- Return (st1, ()) end
+ Return (st1, ())
| BetreeNodeLeaf node ->
let* (st0, content) = betree_load_leaf_node_fwd node.betree_leaf_id st in
let* content0 = betree_node_apply_messages_to_leaf_fwd_back content msgs in
let* len = betree_list_len_fwd (u64 & u64) content0 in
let* i = u64_mul 2 params.betree_params_split_size in
if len >= i
- then begin
+ then
let* (st1, _) =
betree_leaf_split_fwd node content0 params node_id_cnt st0 in
let* (st2, _) =
betree_store_leaf_node_fwd node.betree_leaf_id BetreeListNil st1 in
- Return (st2, ()) end
- else begin
+ Return (st2, ())
+ else
let* (st1, _) =
betree_store_leaf_node_fwd node.betree_leaf_id content0 st0 in
- Return (st1, ()) end
+ Return (st1, ())
end
(** [betree_main::betree::Node::{5}::apply_messages] *)
@@ -750,36 +751,36 @@ and betree_node_apply_messages_back
betree_node_apply_messages_to_internal_fwd_back content msgs in
let* num_msgs = betree_list_len_fwd (u64 & betree_message_t) content0 in
if num_msgs >= params.betree_params_min_flush_size
- then begin
+ then
let* (st1, content1) =
betree_internal_flush_fwd node params node_id_cnt content0 st0 in
let* (node0, node_id_cnt0) =
betree_internal_flush_back node params node_id_cnt content0 st0 in
let* _ =
betree_store_internal_node_fwd node0.betree_internal_id content1 st1 in
- Return (BetreeNodeInternal node0, node_id_cnt0) end
- else begin
+ Return (BetreeNodeInternal node0, node_id_cnt0)
+ else
let* _ =
betree_store_internal_node_fwd node.betree_internal_id content0 st0 in
- Return (BetreeNodeInternal node, node_id_cnt) end
+ Return (BetreeNodeInternal node, node_id_cnt)
| BetreeNodeLeaf node ->
let* (st0, content) = betree_load_leaf_node_fwd node.betree_leaf_id st in
let* content0 = betree_node_apply_messages_to_leaf_fwd_back content msgs in
let* len = betree_list_len_fwd (u64 & u64) content0 in
let* i = u64_mul 2 params.betree_params_split_size in
if len >= i
- then begin
+ then
let* (st1, new_node) =
betree_leaf_split_fwd node content0 params node_id_cnt st0 in
let* _ = betree_store_leaf_node_fwd node.betree_leaf_id BetreeListNil st1
in
let* node_id_cnt0 =
betree_leaf_split_back node content0 params node_id_cnt st0 in
- Return (BetreeNodeInternal new_node, node_id_cnt0) end
- else begin
+ Return (BetreeNodeInternal new_node, node_id_cnt0)
+ else
let* _ = betree_store_leaf_node_fwd node.betree_leaf_id content0 st0 in
Return (BetreeNodeLeaf (Mkbetree_leaf_t node.betree_leaf_id len),
- node_id_cnt) end
+ node_id_cnt)
end
(** [betree_main::betree::Internal::{4}::flush] *)
@@ -797,7 +798,7 @@ and betree_internal_flush_fwd
let (msgs_left, msgs_right) = p in
let* len_left = betree_list_len_fwd (u64 & betree_message_t) msgs_left in
if len_left >= params.betree_params_min_flush_size
- then begin
+ then
let* (st0, _) =
betree_node_apply_messages_fwd self.betree_internal_left params
node_id_cnt msgs_left st in
@@ -806,23 +807,23 @@ and betree_internal_flush_fwd
node_id_cnt msgs_left st in
let* len_right = betree_list_len_fwd (u64 & betree_message_t) msgs_right in
if len_right >= params.betree_params_min_flush_size
- then begin
+ then
let* (st1, _) =
betree_node_apply_messages_fwd self.betree_internal_right params
node_id_cnt0 msgs_right st0 in
let* _ =
betree_node_apply_messages_back self.betree_internal_right params
node_id_cnt0 msgs_right st0 in
- Return (st1, BetreeListNil) end
- else Return (st0, msgs_right) end
- else begin
+ Return (st1, BetreeListNil)
+ else Return (st0, msgs_right)
+ else
let* (st0, _) =
betree_node_apply_messages_fwd self.betree_internal_right params
node_id_cnt msgs_right st in
let* _ =
betree_node_apply_messages_back self.betree_internal_right params
node_id_cnt msgs_right st in
- Return (st0, msgs_left) end
+ Return (st0, msgs_left)
(** [betree_main::betree::Internal::{4}::flush] *)
and betree_internal_flush_back
@@ -839,7 +840,7 @@ and betree_internal_flush_back
let (msgs_left, msgs_right) = p in
let* len_left = betree_list_len_fwd (u64 & betree_message_t) msgs_left in
if len_left >= params.betree_params_min_flush_size
- then begin
+ then
let* (st0, _) =
betree_node_apply_messages_fwd self.betree_internal_left params
node_id_cnt msgs_left st in
@@ -848,22 +849,21 @@ and betree_internal_flush_back
node_id_cnt msgs_left st in
let* len_right = betree_list_len_fwd (u64 & betree_message_t) msgs_right in
if len_right >= params.betree_params_min_flush_size
- then begin
+ then
let* (n0, node_id_cnt1) =
betree_node_apply_messages_back self.betree_internal_right params
node_id_cnt0 msgs_right st0 in
Return (Mkbetree_internal_t self.betree_internal_id
- self.betree_internal_pivot n n0, node_id_cnt1) end
+ self.betree_internal_pivot n n0, node_id_cnt1)
else
Return (Mkbetree_internal_t self.betree_internal_id
self.betree_internal_pivot n self.betree_internal_right, node_id_cnt0)
- end
- else begin
+ else
let* (n, node_id_cnt0) =
betree_node_apply_messages_back self.betree_internal_right params
node_id_cnt msgs_right st in
Return (Mkbetree_internal_t self.betree_internal_id
- self.betree_internal_pivot self.betree_internal_left n, node_id_cnt0) end
+ self.betree_internal_pivot self.betree_internal_left n, node_id_cnt0)
(** [betree_main::betree::Node::{5}::apply] *)
let betree_node_apply_fwd
@@ -994,7 +994,8 @@ let betree_be_tree_lookup_back
self.betree_be_tree_node_id_cnt n)
(** [betree_main::main] *)
-let main_fwd : result unit = Return ()
+let main_fwd : result unit =
+ Return ()
(** Unit test for [betree_main::main] *)
let _ = assert_norm (main_fwd = Return ())