From d281f43fd5dfeab24fe582fd88564f6c1ab7f934 Mon Sep 17 00:00:00 2001 From: Son Ho Date: Mon, 18 Mar 2024 01:39:29 +0100 Subject: Regenerate the constants tests and update Primitives/Base.lean --- tests/fstar/misc/Constants.fst | 50 +++++++++++++++++++++++++++--------------- 1 file changed, 32 insertions(+), 18 deletions(-) (limited to 'tests/fstar') diff --git a/tests/fstar/misc/Constants.fst b/tests/fstar/misc/Constants.fst index 66429c80..3664c7d6 100644 --- a/tests/fstar/misc/Constants.fst +++ b/tests/fstar/misc/Constants.fst @@ -8,17 +8,17 @@ open Primitives (** [constants::X0] Source: 'src/constants.rs', lines 5:0-5:17 *) let x0_body : result u32 = Return 0 -let x0 : u32 = eval_global x0_body +let x0 : u32 = eval_global (x0_body) (** [constants::X1] Source: 'src/constants.rs', lines 7:0-7:17 *) let x1_body : result u32 = Return core_u32_max -let x1 : u32 = eval_global x1_body +let x1 : u32 = eval_global (x1_body) (** [constants::X2] Source: 'src/constants.rs', lines 10:0-10:17 *) let x2_body : result u32 = Return 3 -let x2 : u32 = eval_global x2_body +let x2 : u32 = eval_global (x2_body) (** [constants::incr]: Source: 'src/constants.rs', lines 17:0-17:32 *) @@ -28,7 +28,7 @@ let incr (n : u32) : result u32 = (** [constants::X3] Source: 'src/constants.rs', lines 15:0-15:17 *) let x3_body : result u32 = incr 32 -let x3 : u32 = eval_global x3_body +let x3 : u32 = eval_global (x3_body) (** [constants::mk_pair0]: Source: 'src/constants.rs', lines 23:0-23:51 *) @@ -47,22 +47,22 @@ let mk_pair1 (x : u32) (y1 : u32) : result (pair_t u32 u32) = (** [constants::P0] Source: 'src/constants.rs', lines 31:0-31:24 *) let p0_body : result (u32 & u32) = mk_pair0 0 1 -let p0 : (u32 & u32) = eval_global p0_body +let p0 : (u32 & u32) = eval_global (p0_body) (** [constants::P1] Source: 'src/constants.rs', lines 32:0-32:28 *) let p1_body : result (pair_t u32 u32) = mk_pair1 0 1 -let p1 : pair_t u32 u32 = eval_global p1_body +let p1 : pair_t u32 u32 = eval_global (p1_body) (** [constants::P2] Source: 'src/constants.rs', lines 33:0-33:24 *) let p2_body : result (u32 & u32) = Return (0, 1) -let p2 : (u32 & u32) = eval_global p2_body +let p2 : (u32 & u32) = eval_global (p2_body) (** [constants::P3] Source: 'src/constants.rs', lines 34:0-34:28 *) let p3_body : result (pair_t u32 u32) = Return { x = 0; y = 1 } -let p3 : pair_t u32 u32 = eval_global p3_body +let p3 : pair_t u32 u32 = eval_global (p3_body) (** [constants::Wrap] Source: 'src/constants.rs', lines 49:0-49:18 *) @@ -76,7 +76,7 @@ let wrap_new (t : Type0) (value : t) : result (wrap_t t) = (** [constants::Y] Source: 'src/constants.rs', lines 41:0-41:22 *) let y_body : result (wrap_t i32) = wrap_new i32 2 -let y : wrap_t i32 = eval_global y_body +let y : wrap_t i32 = eval_global (y_body) (** [constants::unwrap_y]: Source: 'src/constants.rs', lines 43:0-43:30 *) @@ -86,12 +86,12 @@ let unwrap_y : result i32 = (** [constants::YVAL] Source: 'src/constants.rs', lines 47:0-47:19 *) let yval_body : result i32 = unwrap_y -let yval : i32 = eval_global yval_body +let yval : i32 = eval_global (yval_body) (** [constants::get_z1::Z1] Source: 'src/constants.rs', lines 62:4-62:17 *) let get_z1_z1_body : result i32 = Return 3 -let get_z1_z1 : i32 = eval_global get_z1_z1_body +let get_z1_z1 : i32 = eval_global (get_z1_z1_body) (** [constants::get_z1]: Source: 'src/constants.rs', lines 61:0-61:28 *) @@ -106,17 +106,17 @@ let add (a : i32) (b : i32) : result i32 = (** [constants::Q1] Source: 'src/constants.rs', lines 74:0-74:17 *) let q1_body : result i32 = Return 5 -let q1 : i32 = eval_global q1_body +let q1 : i32 = eval_global (q1_body) (** [constants::Q2] Source: 'src/constants.rs', lines 75:0-75:17 *) let q2_body : result i32 = Return q1 -let q2 : i32 = eval_global q2_body +let q2 : i32 = eval_global (q2_body) (** [constants::Q3] Source: 'src/constants.rs', lines 76:0-76:17 *) let q3_body : result i32 = add q2 3 -let q3 : i32 = eval_global q3_body +let q3 : i32 = eval_global (q3_body) (** [constants::get_z2]: Source: 'src/constants.rs', lines 70:0-70:28 *) @@ -126,20 +126,34 @@ let get_z2 : result i32 = (** [constants::S1] Source: 'src/constants.rs', lines 80:0-80:18 *) let s1_body : result u32 = Return 6 -let s1 : u32 = eval_global s1_body +let s1 : u32 = eval_global (s1_body) (** [constants::S2] Source: 'src/constants.rs', lines 81:0-81:18 *) let s2_body : result u32 = incr s1 -let s2 : u32 = eval_global s2_body +let s2 : u32 = eval_global (s2_body) (** [constants::S3] Source: 'src/constants.rs', lines 82:0-82:29 *) let s3_body : result (pair_t u32 u32) = Return p3 -let s3 : pair_t u32 u32 = eval_global s3_body +let s3 : pair_t u32 u32 = eval_global (s3_body) (** [constants::S4] Source: 'src/constants.rs', lines 83:0-83:29 *) let s4_body : result (pair_t u32 u32) = mk_pair1 7 8 -let s4 : pair_t u32 u32 = eval_global s4_body +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#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) -- cgit v1.2.3 From 5a1317e51a5854699befb3b470bc346551b1691a Mon Sep 17 00:00:00 2001 From: Son Ho Date: Mon, 18 Mar 2024 02:05:58 +0100 Subject: Regenerate the test files --- tests/fstar/misc/Constants.fst | 36 ++++++++++---------- tests/fstar/traits/Traits.fst | 77 +++++++++++++++++++++++++++++++++++++++--- 2 files changed, 91 insertions(+), 22 deletions(-) (limited to 'tests/fstar') diff --git a/tests/fstar/misc/Constants.fst b/tests/fstar/misc/Constants.fst index 3664c7d6..8d1cf3ce 100644 --- a/tests/fstar/misc/Constants.fst +++ b/tests/fstar/misc/Constants.fst @@ -8,17 +8,17 @@ open Primitives (** [constants::X0] Source: 'src/constants.rs', lines 5:0-5:17 *) let x0_body : result u32 = Return 0 -let x0 : u32 = eval_global (x0_body) +let x0 : u32 = eval_global x0_body (** [constants::X1] Source: 'src/constants.rs', lines 7:0-7:17 *) let x1_body : result u32 = Return core_u32_max -let x1 : u32 = eval_global (x1_body) +let x1 : u32 = eval_global x1_body (** [constants::X2] Source: 'src/constants.rs', lines 10:0-10:17 *) let x2_body : result u32 = Return 3 -let x2 : u32 = eval_global (x2_body) +let x2 : u32 = eval_global x2_body (** [constants::incr]: Source: 'src/constants.rs', lines 17:0-17:32 *) @@ -28,7 +28,7 @@ let incr (n : u32) : result u32 = (** [constants::X3] Source: 'src/constants.rs', lines 15:0-15:17 *) let x3_body : result u32 = incr 32 -let x3 : u32 = eval_global (x3_body) +let x3 : u32 = eval_global x3_body (** [constants::mk_pair0]: Source: 'src/constants.rs', lines 23:0-23:51 *) @@ -47,22 +47,22 @@ let mk_pair1 (x : u32) (y1 : u32) : result (pair_t u32 u32) = (** [constants::P0] Source: 'src/constants.rs', lines 31:0-31:24 *) let p0_body : result (u32 & u32) = mk_pair0 0 1 -let p0 : (u32 & u32) = eval_global (p0_body) +let p0 : (u32 & u32) = eval_global p0_body (** [constants::P1] Source: 'src/constants.rs', lines 32:0-32:28 *) let p1_body : result (pair_t u32 u32) = mk_pair1 0 1 -let p1 : pair_t u32 u32 = eval_global (p1_body) +let p1 : pair_t u32 u32 = eval_global p1_body (** [constants::P2] Source: 'src/constants.rs', lines 33:0-33:24 *) let p2_body : result (u32 & u32) = Return (0, 1) -let p2 : (u32 & u32) = eval_global (p2_body) +let p2 : (u32 & u32) = eval_global p2_body (** [constants::P3] Source: 'src/constants.rs', lines 34:0-34:28 *) let p3_body : result (pair_t u32 u32) = Return { x = 0; y = 1 } -let p3 : pair_t u32 u32 = eval_global (p3_body) +let p3 : pair_t u32 u32 = eval_global p3_body (** [constants::Wrap] Source: 'src/constants.rs', lines 49:0-49:18 *) @@ -76,7 +76,7 @@ let wrap_new (t : Type0) (value : t) : result (wrap_t t) = (** [constants::Y] Source: 'src/constants.rs', lines 41:0-41:22 *) let y_body : result (wrap_t i32) = wrap_new i32 2 -let y : wrap_t i32 = eval_global (y_body) +let y : wrap_t i32 = eval_global y_body (** [constants::unwrap_y]: Source: 'src/constants.rs', lines 43:0-43:30 *) @@ -86,12 +86,12 @@ let unwrap_y : result i32 = (** [constants::YVAL] Source: 'src/constants.rs', lines 47:0-47:19 *) let yval_body : result i32 = unwrap_y -let yval : i32 = eval_global (yval_body) +let yval : i32 = eval_global yval_body (** [constants::get_z1::Z1] Source: 'src/constants.rs', lines 62:4-62:17 *) let get_z1_z1_body : result i32 = Return 3 -let get_z1_z1 : i32 = eval_global (get_z1_z1_body) +let get_z1_z1 : i32 = eval_global get_z1_z1_body (** [constants::get_z1]: Source: 'src/constants.rs', lines 61:0-61:28 *) @@ -106,17 +106,17 @@ let add (a : i32) (b : i32) : result i32 = (** [constants::Q1] Source: 'src/constants.rs', lines 74:0-74:17 *) let q1_body : result i32 = Return 5 -let q1 : i32 = eval_global (q1_body) +let q1 : i32 = eval_global q1_body (** [constants::Q2] Source: 'src/constants.rs', lines 75:0-75:17 *) let q2_body : result i32 = Return q1 -let q2 : i32 = eval_global (q2_body) +let q2 : i32 = eval_global q2_body (** [constants::Q3] Source: 'src/constants.rs', lines 76:0-76:17 *) let q3_body : result i32 = add q2 3 -let q3 : i32 = eval_global (q3_body) +let q3 : i32 = eval_global q3_body (** [constants::get_z2]: Source: 'src/constants.rs', lines 70:0-70:28 *) @@ -126,22 +126,22 @@ let get_z2 : result i32 = (** [constants::S1] Source: 'src/constants.rs', lines 80:0-80:18 *) let s1_body : result u32 = Return 6 -let s1 : u32 = eval_global (s1_body) +let s1 : u32 = eval_global s1_body (** [constants::S2] Source: 'src/constants.rs', lines 81:0-81:18 *) let s2_body : result u32 = incr s1 -let s2 : u32 = eval_global (s2_body) +let s2 : u32 = eval_global s2_body (** [constants::S3] Source: 'src/constants.rs', lines 82:0-82:29 *) let s3_body : result (pair_t u32 u32) = Return p3 -let s3 : pair_t u32 u32 = eval_global (s3_body) +let s3 : pair_t u32 u32 = eval_global s3_body (** [constants::S4] Source: 'src/constants.rs', lines 83:0-83:29 *) let s4_body : result (pair_t u32 u32) = mk_pair1 7 8 -let s4 : pair_t u32 u32 = eval_global (s4_body) +let s4 : pair_t u32 u32 = eval_global s4_body (** [constants::V] Source: 'src/constants.rs', lines 86:0-86:31 *) 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)#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)#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)#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)#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#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) + -- cgit v1.2.3