From 1af63cade04325eb32a62ca23125eea75810822f Mon Sep 17 00:00:00 2001 From: Son Ho Date: Mon, 14 Nov 2022 09:27:24 +0100 Subject: Improve the formatting of the generated code --- tests/coq/misc/External__Funs.v | 26 ++++++++++++++++++-------- tests/coq/misc/NoNestedBorrows.v | 15 ++++++++++----- tests/coq/misc/Paper.v | 10 +++++++--- 3 files changed, 35 insertions(+), 16 deletions(-) (limited to 'tests/coq') diff --git a/tests/coq/misc/External__Funs.v b/tests/coq/misc/External__Funs.v index 021acd6e..e8ecfab8 100644 --- a/tests/coq/misc/External__Funs.v +++ b/tests/coq/misc/External__Funs.v @@ -18,7 +18,8 @@ Definition swap_fwd p0 <- core_mem_swap_back0 T x y st st0; let (st1, _) := p0 in p1 <- core_mem_swap_back1 T x y st st1; - let (st2, _) := p1 in Return (st2, tt) + let (st2, _) := p1 in + Return (st2, tt) . (** [external::swap] *) @@ -31,7 +32,8 @@ Definition swap_back p0 <- core_mem_swap_back0 T x y st st1; let (st2, x0) := p0 in p1 <- core_mem_swap_back1 T x y st st2; - let (_, y0) := p1 in Return (st0, (x0, y0)) + let (_, y0) := p1 in + Return (st0, (x0, y0)) . (** [external::test_new_non_zero_u32] *) @@ -40,13 +42,16 @@ Definition test_new_non_zero_u32_fwd p <- core_num_nonzero_non_zero_u32_new_fwd x st; let (st0, opt) := p in p0 <- core_option_option_unwrap_fwd Core_num_nonzero_non_zero_u32_t opt st0; - let (st1, nzu) := p0 in Return (st1, nzu) + let (st1, nzu) := p0 in + Return (st1, nzu) . (** [external::test_vec] *) Definition test_vec_fwd : result unit := let v := vec_new u32 in - v0 <- vec_push_back u32 v (0 %u32); let _ := v0 in Return tt + v0 <- vec_push_back u32 v (0 %u32); + let _ := v0 in + Return tt . (** [external::custom_swap] *) @@ -57,7 +62,8 @@ Definition custom_swap_fwd p0 <- core_mem_swap_back0 T x y st st0; let (st1, x0) := p0 in p1 <- core_mem_swap_back1 T x y st st1; - let (st2, _) := p1 in Return (st2, x0) + let (st2, _) := p1 in + Return (st2, x0) . (** [external::custom_swap] *) @@ -70,7 +76,8 @@ Definition custom_swap_back p0 <- core_mem_swap_back0 T x y st st1; let (st2, _) := p0 in p1 <- core_mem_swap_back1 T x y st st2; - let (_, y0) := p1 in Return (st0, (ret, y0)) + let (_, y0) := p1 in + Return (st0, (ret, y0)) . (** [external::test_custom_swap] *) @@ -84,7 +91,9 @@ Definition test_custom_swap_back result (state * (u32 * u32)) := p <- custom_swap_back u32 x y st (1 %u32) st0; - let (st1, p0) := p in let (x0, y0) := p0 in Return (st1, (x0, y0)) + let (st1, p0) := p in + let (x0, y0) := p0 in + Return (st1, (x0, y0)) . (** [external::test_swap_non_zero] *) @@ -94,7 +103,8 @@ Definition test_swap_non_zero_fwd let (st0, _) := p in p0 <- swap_back u32 x (0 %u32) st st0; let (st1, p1) := p0 in - let (x0, _) := p1 in if x0 s= 0 %u32 then Fail_ else Return (st1, x0) + let (x0, _) := p1 in + if x0 s= 0 %u32 then Fail_ else Return (st1, x0) . End External__Funs . diff --git a/tests/coq/misc/NoNestedBorrows.v b/tests/coq/misc/NoNestedBorrows.v index 6dc41204..9075d01d 100644 --- a/tests/coq/misc/NoNestedBorrows.v +++ b/tests/coq/misc/NoNestedBorrows.v @@ -94,7 +94,8 @@ Definition get_max_fwd (x : u32) (y : u32) : result u32 := Definition test3_fwd : result unit := x <- get_max_fwd (4 %u32) (3 %u32); y <- get_max_fwd (10 %u32) (11 %u32); - z <- u32_add x y; if negb (z s= 15 %u32) then Fail_ else Return tt + z <- u32_add x y; + if negb (z s= 15 %u32) then Fail_ else Return tt . (** Unit test for [no_nested_borrows::test3] *) @@ -139,7 +140,8 @@ Check (test_list1_fwd )%return. (** [no_nested_borrows::test_box1] *) Definition test_box1_fwd : result unit := let b := 1 %i32 in - let x := b in if negb (x s= 1 %i32) then Fail_ else Return tt + let x := b in + if negb (x s= 1 %i32) then Fail_ else Return tt . (** Unit test for [no_nested_borrows::test_box1] *) @@ -186,7 +188,8 @@ Definition split_list_fwd Definition test_split_list_fwd : result unit := let l := ListNil in p <- split_list_fwd i32 (ListCons (0 %i32) l); - let (hd, _) := p in if negb (hd s= 0 %i32) then Fail_ else Return tt + let (hd, _) := p in + if negb (hd s= 0 %i32) then Fail_ else Return tt . (** Unit test for [no_nested_borrows::test_split_list] *) @@ -281,7 +284,8 @@ Fixpoint list_nth_mut_back else ( i0 <- u32_sub i 1 %u32; - tl0 <- list_nth_mut_back T tl i0 ret; Return (ListCons x tl0) ) + tl0 <- list_nth_mut_back T tl i0 ret; + Return (ListCons x tl0) ) | ListNil => Fail_ end . @@ -298,7 +302,8 @@ Fixpoint list_rev_aux_fwd (** [no_nested_borrows::list_rev] *) Definition list_rev_fwd_back (T : Type) (l : List_t T) : result (List_t T) := let li := mem_replace_fwd (List_t T) l ListNil in - l0 <- list_rev_aux_fwd T li ListNil; Return l0 + l0 <- list_rev_aux_fwd T li ListNil; + Return l0 . (** [no_nested_borrows::test_list_functions] *) diff --git a/tests/coq/misc/Paper.v b/tests/coq/misc/Paper.v index 5d9598eb..e15e0dc1 100644 --- a/tests/coq/misc/Paper.v +++ b/tests/coq/misc/Paper.v @@ -76,7 +76,8 @@ Fixpoint list_nth_mut_back else ( i0 <- u32_sub i 1 %u32; - tl0 <- list_nth_mut_back T tl i0 ret; Return (ListCons x tl0) ) + tl0 <- list_nth_mut_back T tl i0 ret; + Return (ListCons x tl0) ) | ListNil => Fail_ end . @@ -97,7 +98,8 @@ Definition test_nth_fwd : result unit := x <- list_nth_mut_fwd i32 (ListCons (1 %i32) l1) (2 %u32); x0 <- i32_add x 1 %i32; l2 <- list_nth_mut_back i32 (ListCons (1 %i32) l1) (2 %u32) x0; - i <- sum_fwd l2; if negb (i s= 7 %i32) then Fail_ else Return tt + i <- sum_fwd l2; + if negb (i s= 7 %i32) then Fail_ else Return tt . (** Unit test for [paper::test_nth] *) @@ -108,7 +110,9 @@ Definition call_choose_fwd (p : (u32 * u32)) : result u32 := let (px, py) := p in pz <- choose_fwd u32 true px py; pz0 <- u32_add pz 1 %u32; - p0 <- choose_back u32 true px py pz0; let (px0, _) := p0 in Return px0 + p0 <- choose_back u32 true px py pz0; + let (px0, _) := p0 in + Return px0 . End Paper . -- cgit v1.2.3