From 4cffedcded99e4fdf038bfe38a16cba99dc956de Mon Sep 17 00:00:00 2001 From: Son Ho Date: Wed, 23 Feb 2022 18:32:10 +0100 Subject: Track the generated F* files from tests/misc --- tests/misc/Paper.fst | 140 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 140 insertions(+) create mode 100644 tests/misc/Paper.fst (limited to 'tests/misc/Paper.fst') diff --git a/tests/misc/Paper.fst b/tests/misc/Paper.fst new file mode 100644 index 00000000..1ab42726 --- /dev/null +++ b/tests/misc/Paper.fst @@ -0,0 +1,140 @@ +(** THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS *) +(** [paper] *) +module Paper +open Primitives + +#set-options "--z3rlimit 50 --fuel 0 --ifuel 1" + +(** [paper::ref_incr] *) +let ref_incr_fwd_back (x : i32) : result i32 = + begin match i32_add x 1 with + | Fail -> Fail + | Return x0 -> let x1 = x0 in Return x1 + end + +(** [paper::test_incr] *) +let test_incr_fwd : result unit = + begin match ref_incr_fwd_back 0 with + | Fail -> Fail + | Return i -> if not (i = 1) then Fail else Return () + end + +(** Unit test for [paper::test_incr] *) +let _ = assert_norm (test_incr_fwd = Return ()) + +(** [paper::choose] *) +let choose_fwd (t : Type0) (b : bool) (x : t) (y : t) : result t = + let x0 = y in let x1 = x in if b then Return x1 else Return x0 + +(** [paper::choose] *) +let choose_back + (t : Type0) (b : bool) (x : t) (y : t) (ret : t) : result (t & t) = + if b + then let x0 = ret in let y0 = y in Return (x0, y0) + else let x0 = x in let y0 = ret in Return (x0, y0) + +(** [paper::test_choose] *) +let test_choose_fwd : result unit = + begin match choose_fwd i32 true 0 0 with + | Fail -> Fail + | Return i -> + begin match i32_add i 1 with + | Fail -> Fail + | Return z -> + if not (z = 1) + then Fail + else + begin match choose_back i32 true 0 0 z with + | Fail -> Fail + | Return (i0, i1) -> + if not (i0 = 1) + then Fail + else if not (i1 = 0) then Fail else Return () + end + end + end + +(** Unit test for [paper::test_choose] *) +let _ = assert_norm (test_choose_fwd = Return ()) + +(** [paper::List] *) +type list_t (t : Type0) = +| ListCons : t -> list_t t -> list_t t +| ListNil : list_t t + +(** [paper::list_nth_mut] *) +let rec list_nth_mut_fwd (t : Type0) (l : list_t t) (i : u32) : result t = + begin match l with + | ListCons x tl -> + begin match i with + | 0 -> Return x + | _ -> + begin match u32_sub i 1 with + | Fail -> Fail + | Return i0 -> + begin match list_nth_mut_fwd t tl i0 with + | Fail -> Fail + | Return x0 -> let x1 = x0 in Return x1 + end + end + end + | ListNil -> Fail + end + +(** [paper::list_nth_mut] *) +let rec list_nth_mut_back + (t : Type0) (l : list_t t) (i : u32) (ret : t) : result (list_t t) = + begin match l with + | ListCons x tl -> + begin match i with + | 0 -> let x0 = ret in let l0 = ListCons x0 tl in Return l0 + | _ -> + begin match u32_sub i 1 with + | Fail -> Fail + | Return i0 -> + begin match list_nth_mut_back t tl i0 ret with + | Fail -> Fail + | Return l0 -> let l1 = ListCons x l0 in Return l1 + end + end + end + | ListNil -> Fail + end + +(** [paper::sum] *) +let rec sum_fwd (l : list_t i32) : result i32 = + begin match l with + | ListCons x tl -> + begin match sum_fwd tl with + | Fail -> Fail + | Return i -> + begin match i32_add x i with | Fail -> Fail | Return i0 -> Return i0 end + end + | ListNil -> Return 0 + end + +(** [paper::test_nth] *) +let test_nth_fwd : result unit = + let l = ListNil in + let l0 = ListCons 3 l in + let l1 = ListCons 2 l0 in + begin match list_nth_mut_fwd i32 (ListCons 1 l1) 2 with + | Fail -> Fail + | Return i -> + begin match i32_add i 1 with + | Fail -> Fail + | Return x -> + begin match list_nth_mut_back i32 (ListCons 1 l1) 2 x with + | Fail -> Fail + | Return l2 -> + begin match sum_fwd l2 with + | Fail -> Fail + | Return i0 -> if not (i0 = 7) then Fail else Return () + end + end + end + end + +(** Unit test for [paper::test_nth] *) +let _ = assert_norm (test_nth_fwd = Return ()) + -- cgit v1.2.3