summaryrefslogtreecommitdiff
path: root/tests/fstar/traits
diff options
context:
space:
mode:
authorSon Ho2024-04-04 16:20:20 +0200
committerSon Ho2024-04-04 16:20:20 +0200
commitb455f94c841b2423898f39bc9b6a4c35a3db56e3 (patch)
tree2311e681c45d9c7a27d7f728435837b3b6b41971 /tests/fstar/traits
parent57b71cb1bfde1832097163c7169aaf97cf8c7583 (diff)
Regenerate the test files
Diffstat (limited to 'tests/fstar/traits')
-rw-r--r--tests/fstar/traits/Primitives.fst56
-rw-r--r--tests/fstar/traits/Traits.fst48
2 files changed, 52 insertions, 52 deletions
diff --git a/tests/fstar/traits/Primitives.fst b/tests/fstar/traits/Primitives.fst
index fca80829..acdb09dc 100644
--- a/tests/fstar/traits/Primitives.fst
+++ b/tests/fstar/traits/Primitives.fst
@@ -23,11 +23,11 @@ type error : Type0 =
| OutOfFuel
type result (a : Type0) : Type0 =
-| Return : v:a -> result a
+| Ok : v:a -> result a
| Fail : e:error -> result a
// Monadic return operator
-unfold let return (#a : Type0) (x : a) : result a = Return x
+unfold let return (#a : Type0) (x : a) : result a = Ok x
// Monadic bind operator.
// Allows to use the notation:
@@ -36,17 +36,17 @@ unfold let return (#a : Type0) (x : a) : result a = Return x
// ...
// ```
unfold let (let*) (#a #b : Type0) (m: result a)
- (f: (x:a) -> Pure (result b) (requires (m == Return x)) (ensures fun _ -> True)) :
+ (f: (x:a) -> Pure (result b) (requires (m == Ok x)) (ensures fun _ -> True)) :
result b =
match m with
- | Return x -> f x
+ | Ok x -> f x
| Fail e -> Fail e
// Monadic assert(...)
-let massert (b:bool) : result unit = if b then Return () else Fail Failure
+let massert (b:bool) : result unit = if b then Ok () else Fail Failure
// Normalize and unwrap a successful result (used for globals).
-let eval_global (#a : Type0) (x : result a{Return? (normalize_term x)}) : a = Return?.v x
+let eval_global (#a : Type0) (x : result a{Ok? (normalize_term x)}) : a = Ok?.v x
(*** Misc *)
type char = FStar.Char.char
@@ -144,7 +144,7 @@ let scalar_max (ty : scalar_ty) : int =
type scalar (ty : scalar_ty) : eqtype = x:int{scalar_min ty <= x && x <= scalar_max ty}
let mk_scalar (ty : scalar_ty) (x : int) : result (scalar ty) =
- if scalar_min ty <= x && scalar_max ty >= x then Return x else Fail Failure
+ if scalar_min ty <= x && scalar_max ty >= x then Ok x else Fail Failure
let scalar_neg (#ty : scalar_ty) (x : scalar ty) : result (scalar ty) = mk_scalar ty (-x)
@@ -498,9 +498,9 @@ type core_ops_range_Range (a : Type0) = {
(*** [alloc] *)
-let alloc_boxed_Box_deref (t : Type0) (x : t) : result t = Return x
+let alloc_boxed_Box_deref (t : Type0) (x : t) : result t = Ok x
let alloc_boxed_Box_deref_mut (t : Type0) (x : t) : result (t & (t -> result t)) =
- Return (x, (fun x -> Return x))
+ Ok (x, (fun x -> Ok x))
// Trait instance
let alloc_boxed_Box_coreopsDerefInst (self : Type0) : core_ops_deref_Deref self = {
@@ -528,20 +528,20 @@ let mk_array (a : Type0) (n : usize)
l
let array_index_usize (a : Type0) (n : usize) (x : array a n) (i : usize) : result a =
- if i < length x then Return (index x i)
+ if i < length x then Ok (index x i)
else Fail Failure
let array_update_usize (a : Type0) (n : usize) (x : array a n) (i : usize) (nx : a) :
result (array a n) =
- if i < length x then Return (list_update x i nx)
+ if i < length x then Ok (list_update x i nx)
else Fail Failure
let array_index_mut_usize (a : Type0) (n : usize) (x : array a n) (i : usize) :
result (a & (a -> result (array a n))) =
match array_index_usize a n x i with
| Fail e -> Fail e
- | Return v ->
- Return (v, array_update_usize a n x i)
+ | Ok v ->
+ Ok (v, array_update_usize a n x i)
(*** Slice *)
type slice (a : Type0) = s:list a{length s <= usize_max}
@@ -549,30 +549,30 @@ type slice (a : Type0) = s:list a{length s <= usize_max}
let slice_len (a : Type0) (s : slice a) : usize = length s
let slice_index_usize (a : Type0) (x : slice a) (i : usize) : result a =
- if i < length x then Return (index x i)
+ if i < length x then Ok (index x i)
else Fail Failure
let slice_update_usize (a : Type0) (x : slice a) (i : usize) (nx : a) : result (slice a) =
- if i < length x then Return (list_update x i nx)
+ if i < length x then Ok (list_update x i nx)
else Fail Failure
let slice_index_mut_usize (a : Type0) (s : slice a) (i : usize) :
result (a & (a -> result (slice a))) =
match slice_index_usize a s i with
| Fail e -> Fail e
- | Return x ->
- Return (x, slice_update_usize a s i)
+ | Ok x ->
+ Ok (x, slice_update_usize a s i)
(*** Subslices *)
-let array_to_slice (a : Type0) (n : usize) (x : array a n) : result (slice a) = Return x
+let array_to_slice (a : Type0) (n : usize) (x : array a n) : result (slice a) = Ok x
let array_from_slice (a : Type0) (n : usize) (x : array a n) (s : slice a) : result (array a n) =
- if length s = n then Return s
+ if length s = n then Ok s
else Fail Failure
let array_to_slice_mut (a : Type0) (n : usize) (x : array a n) :
result (slice a & (slice a -> result (array a n))) =
- Return (x, array_from_slice a n x)
+ Ok (x, array_from_slice a n x)
// TODO: finish the definitions below (there lacks [List.drop] and [List.take] in the standard library *)
let array_subslice (a : Type0) (n : usize) (x : array a n) (r : core_ops_range_Range usize) : result (slice a) =
@@ -598,16 +598,16 @@ let alloc_vec_Vec_len (a : Type0) (v : alloc_vec_Vec a) : usize = length v
// Helper
let alloc_vec_Vec_index_usize (#a : Type0) (v : alloc_vec_Vec a) (i : usize) : result a =
- if i < length v then Return (index v i) else Fail Failure
+ if i < length v then Ok (index v i) else Fail Failure
// Helper
let alloc_vec_Vec_update_usize (#a : Type0) (v : alloc_vec_Vec a) (i : usize) (x : a) : result (alloc_vec_Vec a) =
- if i < length v then Return (list_update v i x) else Fail Failure
+ if i < length v then Ok (list_update v i x) else Fail Failure
let alloc_vec_Vec_index_mut_usize (#a : Type0) (v: alloc_vec_Vec a) (i: usize) :
result (a & (a → result (alloc_vec_Vec a))) =
match alloc_vec_Vec_index_usize v i with
- | Return x ->
- Return (x, alloc_vec_Vec_update_usize v i)
+ | Ok x ->
+ Ok (x, alloc_vec_Vec_update_usize v i)
| Fail e -> Fail e
let alloc_vec_Vec_push (a : Type0) (v : alloc_vec_Vec a) (x : a) :
@@ -616,17 +616,17 @@ let alloc_vec_Vec_push (a : Type0) (v : alloc_vec_Vec a) (x : a) :
(ensures (fun res ->
match res with
| Fail e -> e == Failure
- | Return v' -> length v' = length v + 1)) =
+ | Ok v' -> length v' = length v + 1)) =
if length v < usize_max then begin
(**) assert_norm(length [x] == 1);
(**) append_length v [x];
(**) assert(length (append v [x]) = length v + 1);
- Return (append v [x])
+ Ok (append v [x])
end
else Fail Failure
let alloc_vec_Vec_insert (a : Type0) (v : alloc_vec_Vec a) (i : usize) (x : a) : result (alloc_vec_Vec a) =
- if i < length v then Return (list_update v i x) else Fail Failure
+ if i < length v then Ok (list_update v i x) else Fail Failure
// Trait declaration: [core::slice::index::private_slice_index::Sealed]
type core_slice_index_private_slice_index_Sealed (self : Type0) = unit
@@ -650,7 +650,7 @@ let core_slice_index_Slice_index
let* x = inst.get i s in
match x with
| None -> Fail Failure
- | Some x -> Return x
+ | Some x -> Ok x
// [core::slice::index::Range:::get]: forward function
let core_slice_index_RangeUsize_get (t : Type0) (i : core_ops_range_Range usize) (s : slice t) :
diff --git a/tests/fstar/traits/Traits.fst b/tests/fstar/traits/Traits.fst
index 199d49bf..1f0293a0 100644
--- a/tests/fstar/traits/Traits.fst
+++ b/tests/fstar/traits/Traits.fst
@@ -12,7 +12,7 @@ noeq type boolTrait_t (self : Type0) = { get_bool : self -> result bool; }
(** [traits::{(traits::BoolTrait for bool)}::get_bool]:
Source: 'src/traits.rs', lines 12:4-12:30 *)
let boolTraitBool_get_bool (self : bool) : result bool =
- Return self
+ Ok self
(** Trait implementation: [traits::{(traits::BoolTrait for bool)}]
Source: 'src/traits.rs', lines 11:0-11:23 *)
@@ -24,18 +24,18 @@ let boolTrait_ret_true
(#self : Type0) (self_clause : boolTrait_t self) (self1 : self) :
result bool
=
- Return true
+ Ok true
(** [traits::test_bool_trait_bool]:
Source: 'src/traits.rs', lines 17:0-17:44 *)
let test_bool_trait_bool (x : bool) : result bool =
let* b = boolTraitBool_get_bool x in
- if b then boolTrait_ret_true boolTraitBool x else Return false
+ if b then boolTrait_ret_true boolTraitBool x else Ok false
(** [traits::{(traits::BoolTrait for core::option::Option<T>)#1}::get_bool]:
Source: 'src/traits.rs', lines 23:4-23:30 *)
let boolTraitOption_get_bool (t : Type0) (self : option t) : result bool =
- begin match self with | None -> Return false | Some _ -> Return true end
+ begin match self with | None -> Ok false | Some _ -> Ok true end
(** Trait implementation: [traits::{(traits::BoolTrait for core::option::Option<T>)#1}]
Source: 'src/traits.rs', lines 22:0-22:31 *)
@@ -47,7 +47,7 @@ let boolTraitOption (t : Type0) : boolTrait_t (option t) = {
Source: 'src/traits.rs', lines 31:0-31:54 *)
let test_bool_trait_option (t : Type0) (x : option t) : result bool =
let* b = boolTraitOption_get_bool t x in
- if b then boolTrait_ret_true (boolTraitOption t) x else Return false
+ if b then boolTrait_ret_true (boolTraitOption t) x else Ok false
(** [traits::test_bool_trait]:
Source: 'src/traits.rs', lines 35:0-35:50 *)
@@ -62,7 +62,7 @@ noeq type toU64_t (self : Type0) = { to_u64 : self -> result u64; }
(** [traits::{(traits::ToU64 for u64)#2}::to_u64]:
Source: 'src/traits.rs', lines 44:4-44:26 *)
let toU64U64_to_u64 (self : u64) : result u64 =
- Return self
+ Ok self
(** Trait implementation: [traits::{(traits::ToU64 for u64)#2}]
Source: 'src/traits.rs', lines 43:0-43:18 *)
@@ -133,7 +133,7 @@ noeq type toType_t (self t : Type0) = { to_type : self -> result t; }
(** [traits::{(traits::ToType<bool> for u64)#5}::to_type]:
Source: 'src/traits.rs', lines 93:4-93:28 *)
let toTypeU64Bool_to_type (self : u64) : result bool =
- Return (self > 0)
+ Ok (self > 0)
(** Trait implementation: [traits::{(traits::ToType<bool> for u64)#5}]
Source: 'src/traits.rs', lines 92:0-92:25 *)
@@ -188,7 +188,7 @@ noeq type testType_test_TestTrait_t (self : Type0) = {
Source: 'src/traits.rs', lines 139:12-139:34 *)
let testType_test_TestTraittraitsTestTypetestTestType1_test
(self : testType_test_TestType1_t) : result bool =
- Return (self > 1)
+ Ok (self > 1)
(** Trait implementation: [traits::{traits::TestType<T>#6}::test::{(traits::{traits::TestType<T>#6}::test::TestTrait for traits::{traits::TestType<T>#6}::test::TestType1)}]
Source: 'src/traits.rs', lines 138:8-138:36 *)
@@ -206,7 +206,7 @@ let testType_test
let* x1 = toU64Inst.to_u64 x in
if x1 > 0
then testType_test_TestTraittraitsTestTypetestTestType1_test 0
- else Return false
+ else Ok false
(** [traits::BoolWrapper]
Source: 'src/traits.rs', lines 150:0-150:22 *)
@@ -231,7 +231,7 @@ let toTypetraitsBoolWrapperT (t : Type0) (toTypeBoolTInst : toType_t bool t) :
Source: 'src/traits.rs', lines 164:4-164:21 *)
let with_const_ty_len2_default_body (self : Type0) (len : usize)
: result usize =
- Return 32
+ Ok 32
let with_const_ty_len2_default (self : Type0) (len : usize) : usize =
eval_global (with_const_ty_len2_default_body self len)
@@ -248,14 +248,14 @@ noeq type withConstTy_t (self : Type0) (len : usize) = {
(** [traits::{(traits::WithConstTy<32: usize> for bool)#8}::LEN1]
Source: 'src/traits.rs', lines 175:4-175:21 *)
-let with_const_ty_bool32_len1_body : result usize = Return 12
+let with_const_ty_bool32_len1_body : result usize = Ok 12
let with_const_ty_bool32_len1 : usize =
eval_global with_const_ty_bool32_len1_body
(** [traits::{(traits::WithConstTy<32: usize> for bool)#8}::f]:
Source: 'src/traits.rs', lines 180:4-180:39 *)
let withConstTyBool32_f (i : u64) (a : array u8 32) : result u64 =
- Return i
+ Ok i
(** Trait implementation: [traits::{(traits::WithConstTy<32: usize> for bool)#8}]
Source: 'src/traits.rs', lines 174:0-174:29 *)
@@ -274,7 +274,7 @@ let use_with_const_ty1
(h : Type0) (len : usize) (withConstTyInst : withConstTy_t h len) :
result usize
=
- Return withConstTyInst.cLEN1
+ Ok withConstTyInst.cLEN1
(** [traits::use_with_const_ty2]:
Source: 'src/traits.rs', lines 187:0-187:73 *)
@@ -283,7 +283,7 @@ let use_with_const_ty2
(w : withConstTyInst.tW) :
result unit
=
- Return ()
+ Ok ()
(** [traits::use_with_const_ty3]:
Source: 'src/traits.rs', lines 189:0-189:80 *)
@@ -297,7 +297,7 @@ let use_with_const_ty3
(** [traits::test_where1]:
Source: 'src/traits.rs', lines 193:0-193:40 *)
let test_where1 (t : Type0) (_x : t) : result unit =
- Return ()
+ Ok ()
(** [traits::test_where2]:
Source: 'src/traits.rs', lines 194:0-194:57 *)
@@ -305,7 +305,7 @@ let test_where2
(t : Type0) (withConstTyT32Inst : withConstTy_t t 32) (_x : u32) :
result unit
=
- Return ()
+ Ok ()
(** Trait declaration: [traits::ParentTrait0]
Source: 'src/traits.rs', lines 200:0-200:22 *)
@@ -347,7 +347,7 @@ let order1
parentTrait0_t u) :
result unit
=
- Return ()
+ Ok ()
(** Trait declaration: [traits::ChildTrait1]
Source: 'src/traits.rs', lines 222:0-222:35 *)
@@ -421,7 +421,7 @@ let parentTrait2U32 : parentTrait2_t u32 = {
(** [traits::{(traits::ChildTrait2 for u32)#13}::convert]:
Source: 'src/traits.rs', lines 273:4-273:29 *)
let childTrait2U32_convert (x : u32) : result u32 =
- Return x
+ Ok x
(** Trait implementation: [traits::{(traits::ChildTrait2 for u32)#13}]
Source: 'src/traits.rs', lines 272:0-272:24 *)
@@ -468,7 +468,7 @@ noeq type trait_t (self : Type0) = { cLEN : usize; }
(** [traits::{(traits::Trait for @Array<T, N>)#14}::LEN]
Source: 'src/traits.rs', lines 315:4-315:20 *)
-let trait_array_len_body (t : Type0) (n : usize) : result usize = Return n
+let trait_array_len_body (t : Type0) (n : usize) : result usize = Ok n
let trait_array_len (t : Type0) (n : usize) : usize =
eval_global (trait_array_len_body t n)
@@ -482,7 +482,7 @@ let traitArray (t : Type0) (n : usize) : trait_t (array t n) = {
Source: 'src/traits.rs', lines 319:4-319:20 *)
let traittraits_wrapper_len_body (t : Type0) (traitInst : trait_t t)
: result usize =
- Return 0
+ Ok 0
let traittraits_wrapper_len (t : Type0) (traitInst : trait_t t) : usize =
eval_global (traittraits_wrapper_len_body t traitInst)
@@ -496,7 +496,7 @@ let traittraitsWrapper (t : Type0) (traitInst : trait_t t) : trait_t (wrapper_t
(** [traits::use_wrapper_len]:
Source: 'src/traits.rs', lines 322:0-322:43 *)
let use_wrapper_len (t : Type0) (traitInst : trait_t t) : result usize =
- Return (traittraitsWrapper t traitInst).cLEN
+ Ok (traittraitsWrapper t traitInst).cLEN
(** [traits::Foo]
Source: 'src/traits.rs', lines 326:0-326:20 *)
@@ -513,7 +513,7 @@ type core_result_Result_t (t e : Type0) =
Source: 'src/traits.rs', lines 332:4-332:33 *)
let foo_foo_body (t u : Type0) (traitInst : trait_t t)
: result (core_result_Result_t t i32) =
- Return (Core_result_Result_Err 0)
+ Ok (Core_result_Result_Err 0)
let foo_foo (t u : Type0) (traitInst : trait_t t)
: core_result_Result_t t i32 =
eval_global (foo_foo_body t u traitInst)
@@ -522,11 +522,11 @@ let foo_foo (t u : Type0) (traitInst : trait_t t)
Source: 'src/traits.rs', lines 335:0-335:48 *)
let use_foo1
(t u : Type0) (traitInst : trait_t t) : result (core_result_Result_t t i32) =
- Return (foo_foo t u traitInst)
+ Ok (foo_foo t u traitInst)
(** [traits::use_foo2]:
Source: 'src/traits.rs', lines 339:0-339:48 *)
let use_foo2
(t u : Type0) (traitInst : trait_t u) : result (core_result_Result_t u i32) =
- Return (foo_foo u t traitInst)
+ Ok (foo_foo u t traitInst)