summaryrefslogtreecommitdiff
path: root/tests/coq/misc
diff options
context:
space:
mode:
Diffstat (limited to 'tests/coq/misc')
-rw-r--r--tests/coq/misc/Constants.v26
-rw-r--r--tests/coq/misc/External_Funs.v8
-rw-r--r--tests/coq/misc/Loops.v18
-rw-r--r--tests/coq/misc/NoNestedBorrows.v56
-rw-r--r--tests/coq/misc/Paper.v16
5 files changed, 60 insertions, 64 deletions
diff --git a/tests/coq/misc/Constants.v b/tests/coq/misc/Constants.v
index cd3880c2..6a5f2696 100644
--- a/tests/coq/misc/Constants.v
+++ b/tests/coq/misc/Constants.v
@@ -7,11 +7,11 @@ Local Open Scope Primitives_scope.
Module Constants.
(** [constants::X0] *)
-Definition x0_body : result u32 := Return (0%u32).
+Definition x0_body : result u32 := Return 0%u32.
Definition x0_c : u32 := x0_body%global.
(** [core::num::u32::{9}::MAX] *)
-Definition core_num_u32_max_body : result u32 := Return (4294967295%u32).
+Definition core_num_u32_max_body : result u32 := Return 4294967295%u32.
Definition core_num_u32_max_c : u32 := core_num_u32_max_body%global.
(** [constants::X1] *)
@@ -19,7 +19,7 @@ Definition x1_body : result u32 := Return core_num_u32_max_c.
Definition x1_c : u32 := x1_body%global.
(** [constants::X2] *)
-Definition x2_body : result u32 := Return (3%u32).
+Definition x2_body : result u32 := Return 3%u32.
Definition x2_c : u32 := x2_body%global.
(** [constants::incr] *)
@@ -27,7 +27,7 @@ Definition incr_fwd (n : u32) : result u32 :=
u32_add n 1%u32.
(** [constants::X3] *)
-Definition x3_body : result u32 := incr_fwd (32%u32).
+Definition x3_body : result u32 := incr_fwd 32%u32.
Definition x3_c : u32 := x3_body%global.
(** [constants::mk_pair0] *)
@@ -48,11 +48,11 @@ Definition mk_pair1_fwd (x : u32) (y : u32) : result (Pair_t u32 u32) :=
.
(** [constants::P0] *)
-Definition p0_body : result (u32 * u32) := mk_pair0_fwd (0%u32) (1%u32).
+Definition p0_body : result (u32 * u32) := mk_pair0_fwd 0%u32 1%u32.
Definition p0_c : (u32 * u32) := p0_body%global.
(** [constants::P1] *)
-Definition p1_body : result (Pair_t u32 u32) := mk_pair1_fwd (0%u32) (1%u32).
+Definition p1_body : result (Pair_t u32 u32) := mk_pair1_fwd 0%u32 1%u32.
Definition p1_c : Pair_t u32 u32 := p1_body%global.
(** [constants::P2] *)
@@ -61,7 +61,7 @@ Definition p2_c : (u32 * u32) := p2_body%global.
(** [constants::P3] *)
Definition p3_body : result (Pair_t u32 u32) :=
- Return {| Pair_x := (0%u32); Pair_y := (1%u32) |}
+ Return {| Pair_x := 0%u32; Pair_y := 1%u32 |}
.
Definition p3_c : Pair_t u32 u32 := p3_body%global.
@@ -77,7 +77,7 @@ Definition wrap_new_fwd (T : Type) (val : T) : result (Wrap_t T) :=
.
(** [constants::Y] *)
-Definition y_body : result (Wrap_t i32) := wrap_new_fwd i32 (2%i32).
+Definition y_body : result (Wrap_t i32) := wrap_new_fwd i32 2%i32.
Definition y_c : Wrap_t i32 := y_body%global.
(** [constants::unwrap_y] *)
@@ -89,7 +89,7 @@ Definition yval_body : result i32 := unwrap_y_fwd.
Definition yval_c : i32 := yval_body%global.
(** [constants::get_z1::Z1] *)
-Definition get_z1_z1_body : result i32 := Return (3%i32).
+Definition get_z1_z1_body : result i32 := Return 3%i32.
Definition get_z1_z1_c : i32 := get_z1_z1_body%global.
(** [constants::get_z1] *)
@@ -101,7 +101,7 @@ Definition add_fwd (a : i32) (b : i32) : result i32 :=
i32_add a b.
(** [constants::Q1] *)
-Definition q1_body : result i32 := Return (5%i32).
+Definition q1_body : result i32 := Return 5%i32.
Definition q1_c : i32 := q1_body%global.
(** [constants::Q2] *)
@@ -109,7 +109,7 @@ Definition q2_body : result i32 := Return q1_c.
Definition q2_c : i32 := q2_body%global.
(** [constants::Q3] *)
-Definition q3_body : result i32 := add_fwd q2_c (3%i32).
+Definition q3_body : result i32 := add_fwd q2_c 3%i32.
Definition q3_c : i32 := q3_body%global.
(** [constants::get_z2] *)
@@ -118,7 +118,7 @@ Definition get_z2_fwd : result i32 :=
.
(** [constants::S1] *)
-Definition s1_body : result u32 := Return (6%u32).
+Definition s1_body : result u32 := Return 6%u32.
Definition s1_c : u32 := s1_body%global.
(** [constants::S2] *)
@@ -130,7 +130,7 @@ Definition s3_body : result (Pair_t u32 u32) := Return p3_c.
Definition s3_c : Pair_t u32 u32 := s3_body%global.
(** [constants::S4] *)
-Definition s4_body : result (Pair_t u32 u32) := mk_pair1_fwd (7%u32) (8%u32).
+Definition s4_body : result (Pair_t u32 u32) := mk_pair1_fwd 7%u32 8%u32.
Definition s4_c : Pair_t u32 u32 := s4_body%global.
End Constants .
diff --git a/tests/coq/misc/External_Funs.v b/tests/coq/misc/External_Funs.v
index b5476f25..05dd8f2e 100644
--- a/tests/coq/misc/External_Funs.v
+++ b/tests/coq/misc/External_Funs.v
@@ -46,7 +46,7 @@ Definition test_new_non_zero_u32_fwd
(** [external::test_vec] *)
Definition test_vec_fwd : result unit :=
- let v := vec_new u32 in _ <- vec_push_back u32 v (0%u32); Return tt
+ let v := vec_new u32 in _ <- vec_push_back u32 v 0%u32; Return tt
.
(** Unit test for [external::test_vec] *)
@@ -89,15 +89,15 @@ Definition test_custom_swap_back
(x : u32) (y : u32) (st : state) (st0 : state) :
result (state * (u32 * u32))
:=
- custom_swap_back u32 x y st (1%u32) st0
+ custom_swap_back u32 x y st 1%u32 st0
.
(** [external::test_swap_non_zero] *)
Definition test_swap_non_zero_fwd
(x : u32) (st : state) : result (state * u32) :=
- p <- swap_fwd u32 x (0%u32) st;
+ p <- swap_fwd u32 x 0%u32 st;
let (st0, _) := p in
- p0 <- swap_back u32 x (0%u32) st st0;
+ 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_ Failure else Return (st1, x0)
diff --git a/tests/coq/misc/Loops.v b/tests/coq/misc/Loops.v
index bcbfc8df..a5cb3688 100644
--- a/tests/coq/misc/Loops.v
+++ b/tests/coq/misc/Loops.v
@@ -19,7 +19,7 @@ Fixpoint sum_loop_fwd (n : nat) (max : u32) (i : u32) (s : u32) : result u32 :=
(** [loops::sum] *)
Definition sum_fwd (n : nat) (max : u32) : result u32 :=
- sum_loop_fwd n max (0%u32) (0%u32)
+ sum_loop_fwd n max 0%u32 0%u32
.
(** [loops::sum_with_mut_borrows] *)
@@ -39,7 +39,7 @@ Fixpoint sum_with_mut_borrows_loop_fwd
(** [loops::sum_with_mut_borrows] *)
Definition sum_with_mut_borrows_fwd (n : nat) (max : u32) : result u32 :=
- sum_with_mut_borrows_loop_fwd n max (0%u32) (0%u32)
+ sum_with_mut_borrows_loop_fwd n max 0%u32 0%u32
.
(** [loops::sum_with_shared_borrows] *)
@@ -59,7 +59,7 @@ Fixpoint sum_with_shared_borrows_loop_fwd
(** [loops::sum_with_shared_borrows] *)
Definition sum_with_shared_borrows_fwd (n : nat) (max : u32) : result u32 :=
- sum_with_shared_borrows_loop_fwd n max (0%u32) (0%u32)
+ sum_with_shared_borrows_loop_fwd n max 0%u32 0%u32
.
(** [loops::clear] *)
@@ -72,7 +72,7 @@ Fixpoint clear_loop_fwd_back
if i s< i0
then (
i1 <- usize_add i 1%usize;
- v0 <- vec_index_mut_back u32 v i (0%u32);
+ v0 <- vec_index_mut_back u32 v i 0%u32;
clear_loop_fwd_back n0 v0 i1)
else Return v
end
@@ -80,7 +80,7 @@ Fixpoint clear_loop_fwd_back
(** [loops::clear] *)
Definition clear_fwd_back (n : nat) (v : vec u32) : result (vec u32) :=
- clear_loop_fwd_back n v (0%usize)
+ clear_loop_fwd_back n v 0%usize
.
(** [loops::List] *)
@@ -201,7 +201,7 @@ Fixpoint get_elem_mut_loop_fwd
(** [loops::get_elem_mut] *)
Definition get_elem_mut_fwd
(n : nat) (slots : vec (List_t usize)) (x : usize) : result usize :=
- l <- vec_index_mut_fwd (List_t usize) slots (0%usize);
+ l <- vec_index_mut_fwd (List_t usize) slots 0%usize;
get_elem_mut_loop_fwd n x l
.
@@ -228,9 +228,9 @@ Definition get_elem_mut_back
(n : nat) (slots : vec (List_t usize)) (x : usize) (ret : usize) :
result (vec (List_t usize))
:=
- l <- vec_index_mut_fwd (List_t usize) slots (0%usize);
+ l <- vec_index_mut_fwd (List_t usize) slots 0%usize;
l0 <- get_elem_mut_loop_back n x l ret;
- vec_index_mut_back (List_t usize) slots (0%usize) l0
+ vec_index_mut_back (List_t usize) slots 0%usize l0
.
(** [loops::get_elem_shared] *)
@@ -250,7 +250,7 @@ Fixpoint get_elem_shared_loop_fwd
(** [loops::get_elem_shared] *)
Definition get_elem_shared_fwd
(n : nat) (slots : vec (List_t usize)) (x : usize) : result usize :=
- l <- vec_index_fwd (List_t usize) slots (0%usize);
+ l <- vec_index_fwd (List_t usize) slots 0%usize;
get_elem_shared_loop_fwd n x l
.
diff --git a/tests/coq/misc/NoNestedBorrows.v b/tests/coq/misc/NoNestedBorrows.v
index 826b52b6..96d62711 100644
--- a/tests/coq/misc/NoNestedBorrows.v
+++ b/tests/coq/misc/NoNestedBorrows.v
@@ -87,8 +87,8 @@ Definition get_max_fwd (x : u32) (y : u32) : result u32 :=
(** [no_nested_borrows::test3] *)
Definition test3_fwd : result unit :=
- x <- get_max_fwd (4%u32) (3%u32);
- y <- get_max_fwd (10%u32) (11%u32);
+ 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_ Failure else Return tt
.
@@ -98,8 +98,7 @@ Check (test3_fwd )%return.
(** [no_nested_borrows::test_neg1] *)
Definition test_neg1_fwd : result unit :=
- y <- i32_neg (3%i32);
- if negb (y s= (-3)%i32) then Fail_ Failure else Return tt
+ y <- i32_neg 3%i32; if negb (y s= (-3)%i32) then Fail_ Failure else Return tt
.
(** Unit test for [no_nested_borrows::test_neg1] *)
@@ -162,7 +161,7 @@ Definition test_panic_fwd (b : bool) : result unit :=
(** [no_nested_borrows::test_copy_int] *)
Definition test_copy_int_fwd : result unit :=
- y <- copy_int_fwd (0%i32);
+ y <- copy_int_fwd 0%i32;
if negb (0%i32 s= y) then Fail_ Failure else Return tt
.
@@ -177,7 +176,7 @@ Definition is_cons_fwd (T : Type) (l : List_t T) : result bool :=
(** [no_nested_borrows::test_is_cons] *)
Definition test_is_cons_fwd : result unit :=
let l := ListNil in
- b <- is_cons_fwd i32 (ListCons (0%i32) l);
+ b <- is_cons_fwd i32 (ListCons 0%i32 l);
if negb b then Fail_ Failure else Return tt
.
@@ -196,7 +195,7 @@ Definition split_list_fwd
(** [no_nested_borrows::test_split_list] *)
Definition test_split_list_fwd : result unit :=
let l := ListNil in
- p <- split_list_fwd i32 (ListCons (0%i32) l);
+ p <- split_list_fwd i32 (ListCons 0%i32 l);
let (hd, _) := p in
if negb (hd s= 0%i32) then Fail_ Failure else Return tt
.
@@ -217,12 +216,12 @@ Definition choose_back
(** [no_nested_borrows::choose_test] *)
Definition choose_test_fwd : result unit :=
- z <- choose_fwd i32 true (0%i32) (0%i32);
+ z <- choose_fwd i32 true 0%i32 0%i32;
z0 <- i32_add z 1%i32;
if negb (z0 s= 1%i32)
then Fail_ Failure
else (
- p <- choose_back i32 true (0%i32) (0%i32) z0;
+ p <- choose_back i32 true 0%i32 0%i32 z0;
let (x, y) := p in
if negb (x s= 1%i32)
then Fail_ Failure
@@ -258,7 +257,7 @@ Arguments TreeNode {T} _ _ _.
Fixpoint list_length_fwd (T : Type) (l : List_t T) : result u32 :=
match l with
| ListCons t l1 => i <- list_length_fwd T l1; u32_add 1%u32 i
- | ListNil => Return (0%u32)
+ | ListNil => Return 0%u32
end
.
@@ -317,34 +316,34 @@ Definition list_rev_fwd_back (T : Type) (l : List_t T) : result (List_t T) :=
(** [no_nested_borrows::test_list_functions] *)
Definition test_list_functions_fwd : result unit :=
let l := ListNil in
- let l0 := ListCons (2%i32) l in
- let l1 := ListCons (1%i32) l0 in
- i <- list_length_fwd i32 (ListCons (0%i32) l1);
+ let l0 := ListCons 2%i32 l in
+ let l1 := ListCons 1%i32 l0 in
+ i <- list_length_fwd i32 (ListCons 0%i32 l1);
if negb (i s= 3%u32)
then Fail_ Failure
else (
- i0 <- list_nth_shared_fwd i32 (ListCons (0%i32) l1) (0%u32);
+ i0 <- list_nth_shared_fwd i32 (ListCons 0%i32 l1) 0%u32;
if negb (i0 s= 0%i32)
then Fail_ Failure
else (
- i1 <- list_nth_shared_fwd i32 (ListCons (0%i32) l1) (1%u32);
+ i1 <- list_nth_shared_fwd i32 (ListCons 0%i32 l1) 1%u32;
if negb (i1 s= 1%i32)
then Fail_ Failure
else (
- i2 <- list_nth_shared_fwd i32 (ListCons (0%i32) l1) (2%u32);
+ i2 <- list_nth_shared_fwd i32 (ListCons 0%i32 l1) 2%u32;
if negb (i2 s= 2%i32)
then Fail_ Failure
else (
- ls <- list_nth_mut_back i32 (ListCons (0%i32) l1) (1%u32) (3%i32);
- i3 <- list_nth_shared_fwd i32 ls (0%u32);
+ ls <- list_nth_mut_back i32 (ListCons 0%i32 l1) 1%u32 3%i32;
+ i3 <- list_nth_shared_fwd i32 ls 0%u32;
if negb (i3 s= 0%i32)
then Fail_ Failure
else (
- i4 <- list_nth_shared_fwd i32 ls (1%u32);
+ i4 <- list_nth_shared_fwd i32 ls 1%u32;
if negb (i4 s= 3%i32)
then Fail_ Failure
else (
- i5 <- list_nth_shared_fwd i32 ls (2%u32);
+ i5 <- list_nth_shared_fwd i32 ls 2%u32;
if negb (i5 s= 2%i32) then Fail_ Failure else Return tt))))))
.
@@ -448,7 +447,7 @@ Arguments Struct_with_pair_p {T1} {T2}.
(** [no_nested_borrows::new_pair1] *)
Definition new_pair1_fwd : result (Struct_with_pair_t u32 u32) :=
- Return {| Struct_with_pair_p := {| Pair_x := (1%u32); Pair_y := (2%u32) |} |}
+ Return {| Struct_with_pair_p := {| Pair_x := 1%u32; Pair_y := 2%u32 |} |}
.
(** [no_nested_borrows::test_constants] *)
@@ -486,29 +485,26 @@ Check (test_weird_borrows1_fwd )%return.
(** [no_nested_borrows::test_mem_replace] *)
Definition test_mem_replace_fwd_back (px : u32) : result u32 :=
- let y := mem_replace_fwd u32 px (1%u32) in
- if negb (y s= 0%u32) then Fail_ Failure else Return (2%u32)
+ let y := mem_replace_fwd u32 px 1%u32 in
+ if negb (y s= 0%u32) then Fail_ Failure else Return 2%u32
.
(** [no_nested_borrows::test_shared_borrow_bool1] *)
Definition test_shared_borrow_bool1_fwd (b : bool) : result u32 :=
- if b then Return (0%u32) else Return (1%u32)
+ if b then Return 0%u32 else Return 1%u32
.
(** [no_nested_borrows::test_shared_borrow_bool2] *)
Definition test_shared_borrow_bool2_fwd : result u32 :=
- Return (0%u32).
+ Return 0%u32.
(** [no_nested_borrows::test_shared_borrow_enum1] *)
Definition test_shared_borrow_enum1_fwd (l : List_t u32) : result u32 :=
- match l with
- | ListCons i l0 => Return (1%u32)
- | ListNil => Return (0%u32)
- end
+ match l with | ListCons i l0 => Return 1%u32 | ListNil => Return 0%u32 end
.
(** [no_nested_borrows::test_shared_borrow_enum2] *)
Definition test_shared_borrow_enum2_fwd : result u32 :=
- Return (0%u32).
+ Return 0%u32.
End NoNestedBorrows .
diff --git a/tests/coq/misc/Paper.v b/tests/coq/misc/Paper.v
index 8045222d..513bc749 100644
--- a/tests/coq/misc/Paper.v
+++ b/tests/coq/misc/Paper.v
@@ -12,7 +12,7 @@ Definition ref_incr_fwd_back (x : i32) : result i32 :=
(** [paper::test_incr] *)
Definition test_incr_fwd : result unit :=
- x <- ref_incr_fwd_back (0%i32);
+ x <- ref_incr_fwd_back 0%i32;
if negb (x s= 1%i32) then Fail_ Failure else Return tt
.
@@ -32,12 +32,12 @@ Definition choose_back
(** [paper::test_choose] *)
Definition test_choose_fwd : result unit :=
- z <- choose_fwd i32 true (0%i32) (0%i32);
+ z <- choose_fwd i32 true 0%i32 0%i32;
z0 <- i32_add z 1%i32;
if negb (z0 s= 1%i32)
then Fail_ Failure
else (
- p <- choose_back i32 true (0%i32) (0%i32) z0;
+ p <- choose_back i32 true 0%i32 0%i32 z0;
let (x, y) := p in
if negb (x s= 1%i32)
then Fail_ Failure
@@ -86,18 +86,18 @@ Fixpoint list_nth_mut_back
Fixpoint sum_fwd (l : List_t i32) : result i32 :=
match l with
| ListCons x tl => i <- sum_fwd tl; i32_add x i
- | ListNil => Return (0%i32)
+ | ListNil => Return 0%i32
end
.
(** [paper::test_nth] *)
Definition test_nth_fwd : result unit :=
let l := ListNil in
- let l0 := ListCons (3%i32) l in
- let l1 := ListCons (2%i32) l0 in
- x <- list_nth_mut_fwd i32 (ListCons (1%i32) l1) (2%u32);
+ let l0 := ListCons 3%i32 l in
+ let l1 := ListCons 2%i32 l0 in
+ 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;
+ 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_ Failure else Return tt
.