diff options
author | Son HO | 2024-03-18 07:23:00 +0100 |
---|---|---|
committer | GitHub | 2024-03-18 07:23:00 +0100 |
commit | a24f42ff7f0ae3c2aeb51decb0d0c90d6e50ffac (patch) | |
tree | 7c9e526912d4fcbde4ed2ff4c17988fd5c89c96e /tests/fstar | |
parent | d56946242859e0d375c1d44585b9da6d5fbe94cb (diff) | |
parent | 9e230d0c4378b5c992c820cc1f4322896f739095 (diff) |
Merge pull request #92 from AeneasVerif/son/globals
Add generics to constants/globals
Diffstat (limited to 'tests/fstar')
-rw-r--r-- | tests/fstar/misc/Constants.fst | 14 | ||||
-rw-r--r-- | tests/fstar/traits/Traits.fst | 77 |
2 files changed, 87 insertions, 4 deletions
diff --git a/tests/fstar/misc/Constants.fst b/tests/fstar/misc/Constants.fst index 66429c80..8d1cf3ce 100644 --- a/tests/fstar/misc/Constants.fst +++ b/tests/fstar/misc/Constants.fst @@ -143,3 +143,17 @@ let s3 : pair_t u32 u32 = eval_global s3_body let s4_body : result (pair_t u32 u32) = mk_pair1 7 8 let s4 : pair_t u32 u32 = eval_global s4_body +(** [constants::V] + Source: 'src/constants.rs', lines 86:0-86:31 *) +type v_t (t : Type0) (n : usize) = { x : array t n; } + +(** [constants::{constants::V<T, N>#1}::LEN] + Source: 'src/constants.rs', lines 91:4-91:24 *) +let v_len_body (t : Type0) (n : usize) : result usize = Return n +let v_len (t : Type0) (n : usize) : usize = eval_global (v_len_body t n) + +(** [constants::use_v]: + Source: 'src/constants.rs', lines 94:0-94:42 *) +let use_v (t : Type0) (n : usize) : result usize = + Return (v_len t n) + diff --git a/tests/fstar/traits/Traits.fst b/tests/fstar/traits/Traits.fst index 466fb482..fba564a5 100644 --- a/tests/fstar/traits/Traits.fst +++ b/tests/fstar/traits/Traits.fst @@ -229,9 +229,11 @@ let toTypetraitsBoolWrapperT (t : Type0) (toTypeBoolTInst : toType_t bool t) : (** [traits::WithConstTy::LEN2] Source: 'src/traits.rs', lines 164:4-164:21 *) -let with_const_ty_len2_default_body : result usize = Return 32 -let with_const_ty_len2_default : usize = - eval_global with_const_ty_len2_default_body +let with_const_ty_len2_default_body (self : Type0) (len : usize) + : result usize = + Return 32 +let with_const_ty_len2_default (self : Type0) (len : usize) : usize = + eval_global (with_const_ty_len2_default_body self len) (** Trait declaration: [traits::WithConstTy] Source: 'src/traits.rs', lines 161:0-161:39 *) @@ -259,7 +261,7 @@ let withConstTyBool32_f (i : u64) (a : array u8 32) : result u64 = Source: 'src/traits.rs', lines 174:0-174:29 *) let withConstTyBool32 : withConstTy_t bool 32 = { cLEN1 = with_const_ty_bool32_len1; - cLEN2 = with_const_ty_len2_default; + cLEN2 = with_const_ty_len2_default bool 32; tV = u8; tW = u64; tW_clause_0 = toU64U64; @@ -460,3 +462,70 @@ let test_get_trait (t : Type0) (getTraitInst : getTrait_t t) (x : t) : result getTraitInst.tW = getTraitInst.get_w x +(** Trait declaration: [traits::Trait] + Source: 'src/traits.rs', lines 310:0-310:15 *) +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 (t : Type0) (n : usize) : usize = + eval_global (trait_array_len_body t n) + +(** Trait implementation: [traits::{(traits::Trait for @Array<T, N>)#14}] + Source: 'src/traits.rs', lines 314:0-314:40 *) +let traitArray (t : Type0) (n : usize) : trait_t (array t n) = { + cLEN = trait_array_len t n; +} + +(** [traits::{(traits::Trait for traits::Wrapper<T>)#15}::LEN] + Source: 'src/traits.rs', lines 319:4-319:20 *) +let traittraits_wrapper_len_body (t : Type0) (traitInst : trait_t t) + : result usize = + Return 0 +let traittraits_wrapper_len (t : Type0) (traitInst : trait_t t) : usize = + eval_global (traittraits_wrapper_len_body t traitInst) + +(** Trait implementation: [traits::{(traits::Trait for traits::Wrapper<T>)#15}] + Source: 'src/traits.rs', lines 318:0-318:35 *) +let traittraitsWrapper (t : Type0) (traitInst : trait_t t) : trait_t (wrapper_t + t) = { + cLEN = traittraits_wrapper_len t traitInst; +} + +(** [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 + +(** [traits::Foo] + Source: 'src/traits.rs', lines 326:0-326:20 *) +type foo_t (t u : Type0) = { x : t; y : u; } + +(** [core::result::Result] + Source: '/rustc/d59363ad0b6391b7fc5bbb02c9ccf9300eef3753/library/core/src/result.rs', lines 502:0-502:21 *) +type core_result_Result_t (t e : Type0) = +| Core_result_Result_Ok : t -> core_result_Result_t t e +| Core_result_Result_Err : e -> core_result_Result_t t e + +(** [traits::{traits::Foo<T, U>#16}::FOO] + 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) +let foo_foo (t u : Type0) (traitInst : trait_t t) + : core_result_Result_t t i32 = + eval_global (foo_foo_body t u traitInst) + +(** [traits::use_foo1]: + 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) + +(** [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) + |