summaryrefslogtreecommitdiff
path: root/tests/lean/External
diff options
context:
space:
mode:
Diffstat (limited to 'tests/lean/External')
-rw-r--r--tests/lean/External/ExternalFuns.lean9
-rw-r--r--tests/lean/External/Funs.lean36
-rw-r--r--tests/lean/External/FunsExternal.lean33
-rw-r--r--tests/lean/External/FunsExternal_Template.lean29
-rw-r--r--tests/lean/External/Opaque.lean14
-rw-r--r--tests/lean/External/Types.lean5
6 files changed, 88 insertions, 38 deletions
diff --git a/tests/lean/External/ExternalFuns.lean b/tests/lean/External/ExternalFuns.lean
deleted file mode 100644
index d63db2ac..00000000
--- a/tests/lean/External/ExternalFuns.lean
+++ /dev/null
@@ -1,9 +0,0 @@
-import Base
-import External.Types
-import External.Opaque
-
-namespace External
-
-def opaque_defs : OpaqueDefs := sorry
-
-end External
diff --git a/tests/lean/External/Funs.lean b/tests/lean/External/Funs.lean
index e36987e0..6bfffc33 100644
--- a/tests/lean/External/Funs.lean
+++ b/tests/lean/External/Funs.lean
@@ -2,18 +2,17 @@
-- [external]: function definitions
import Base
import External.Types
-import External.ExternalFuns
+import External.FunsExternal
open Primitives
-
-namespace External
+namespace external
/- [external::swap] -/
def swap_fwd
(T : Type) (x : T) (y : T) (st : State) : Result (State × Unit) :=
do
- let (st0, _) ← opaque_defs.core_mem_swap_fwd T x y st
- let (st1, _) ← opaque_defs.core_mem_swap_back0 T x y st st0
- let (st2, _) ← opaque_defs.core_mem_swap_back1 T x y st st1
+ let (st0, _) ← core.mem.swap_fwd T x y st
+ let (st1, _) ← core.mem.swap_back0 T x y st st0
+ let (st2, _) ← core.mem.swap_back1 T x y st st1
Result.ret (st2, ())
/- [external::swap] -/
@@ -22,18 +21,17 @@ def swap_back
Result (State × (T × T))
:=
do
- let (st1, _) ← opaque_defs.core_mem_swap_fwd T x y st
- let (st2, x0) ← opaque_defs.core_mem_swap_back0 T x y st st1
- let (_, y0) ← opaque_defs.core_mem_swap_back1 T x y st st2
+ let (st1, _) ← core.mem.swap_fwd T x y st
+ let (st2, x0) ← core.mem.swap_back0 T x y st st1
+ let (_, y0) ← core.mem.swap_back1 T x y st st2
Result.ret (st0, (x0, y0))
/- [external::test_new_non_zero_u32] -/
def test_new_non_zero_u32_fwd
(x : U32) (st : State) : Result (State × core_num_nonzero_non_zero_u32_t) :=
do
- let (st0, opt) ← opaque_defs.core_num_nonzero_non_zero_u32_new_fwd x st
- opaque_defs.core_option_option_unwrap_fwd core_num_nonzero_non_zero_u32_t
- opt st0
+ let (st0, opt) ← core.num.nonzero.NonZeroU32.new_fwd x st
+ core.option.Option.unwrap_fwd core_num_nonzero_non_zero_u32_t opt st0
/- [external::test_vec] -/
def test_vec_fwd : Result Unit :=
@@ -49,9 +47,9 @@ def test_vec_fwd : Result Unit :=
def custom_swap_fwd
(T : Type) (x : T) (y : T) (st : State) : Result (State × T) :=
do
- let (st0, _) ← opaque_defs.core_mem_swap_fwd T x y st
- let (st1, x0) ← opaque_defs.core_mem_swap_back0 T x y st st0
- let (st2, _) ← opaque_defs.core_mem_swap_back1 T x y st st1
+ let (st0, _) ← core.mem.swap_fwd T x y st
+ let (st1, x0) ← core.mem.swap_back0 T x y st st0
+ let (st2, _) ← core.mem.swap_back1 T x y st st1
Result.ret (st2, x0)
/- [external::custom_swap] -/
@@ -60,9 +58,9 @@ def custom_swap_back
Result (State × (T × T))
:=
do
- let (st1, _) ← opaque_defs.core_mem_swap_fwd T x y st
- let (st2, _) ← opaque_defs.core_mem_swap_back0 T x y st st1
- let (_, y0) ← opaque_defs.core_mem_swap_back1 T x y st st2
+ let (st1, _) ← core.mem.swap_fwd T x y st
+ let (st2, _) ← core.mem.swap_back0 T x y st st1
+ let (_, y0) ← core.mem.swap_back1 T x y st st2
Result.ret (st0, (ret0, y0))
/- [external::test_custom_swap] -/
@@ -88,4 +86,4 @@ def test_swap_non_zero_fwd (x : U32) (st : State) : Result (State × U32) :=
then Result.fail Error.panic
else Result.ret (st1, x0)
-end External
+end external
diff --git a/tests/lean/External/FunsExternal.lean b/tests/lean/External/FunsExternal.lean
new file mode 100644
index 00000000..5326dd77
--- /dev/null
+++ b/tests/lean/External/FunsExternal.lean
@@ -0,0 +1,33 @@
+-- [external]: templates for the external functions.
+import Base
+import External.Types
+open Primitives
+open external
+
+-- TODO: fill those bodies
+
+/- [core::mem::swap] -/
+def core.mem.swap_fwd
+ (T : Type) : T → T → State → Result (State × Unit) :=
+ fun _x _y s => .ret (s, ())
+
+/- [core::mem::swap] -/
+def core.mem.swap_back0
+ (T : Type) : T → T → State → State → Result (State × T) :=
+ fun _x y _s0 s1 => .ret (s1, y)
+
+/- [core::mem::swap] -/
+def core.mem.swap_back1
+ (T : Type) : T → T → State → State → Result (State × T) :=
+ fun x _y _s0 s1 => .ret (s1, x)
+
+/- [core::num::nonzero::NonZeroU32::{14}::new] -/
+def core.num.nonzero.NonZeroU32.new_fwd
+ :
+ U32 → State → Result (State × (Option core_num_nonzero_non_zero_u32_t)) :=
+ fun _ _ => .fail .panic
+
+/- [core::option::Option::{0}::unwrap] -/
+def core.option.Option.unwrap_fwd
+ (T : Type) : Option T → State → Result (State × T) :=
+ fun _ _ => .fail .panic
diff --git a/tests/lean/External/FunsExternal_Template.lean b/tests/lean/External/FunsExternal_Template.lean
new file mode 100644
index 00000000..d6c0eb1d
--- /dev/null
+++ b/tests/lean/External/FunsExternal_Template.lean
@@ -0,0 +1,29 @@
+-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS
+-- [external]: external functions.
+-- This is a template file: rename it to "FunsExternal.lean" and fill the holes.
+import Base
+import External.Types
+open Primitives
+open external
+
+/- [core::mem::swap] -/
+axiom core.mem.swap_fwd
+ (T : Type) : T → T → State → Result (State × Unit)
+
+/- [core::mem::swap] -/
+axiom core.mem.swap_back0
+ (T : Type) : T → T → State → State → Result (State × T)
+
+/- [core::mem::swap] -/
+axiom core.mem.swap_back1
+ (T : Type) : T → T → State → State → Result (State × T)
+
+/- [core::num::nonzero::NonZeroU32::{14}::new] -/
+axiom core.num.nonzero.NonZeroU32.new_fwd
+ :
+ U32 → State → Result (State × (Option core_num_nonzero_non_zero_u32_t))
+
+/- [core::option::Option::{0}::unwrap] -/
+axiom core.option.Option.unwrap_fwd
+ (T : Type) : Option T → State → Result (State × T)
+
diff --git a/tests/lean/External/Opaque.lean b/tests/lean/External/Opaque.lean
index 1c0db095..d0297523 100644
--- a/tests/lean/External/Opaque.lean
+++ b/tests/lean/External/Opaque.lean
@@ -4,29 +4,29 @@ import Base
import External.Types
open Primitives
-namespace External
+namespace external
structure OpaqueDefs where
/- [core::mem::swap] -/
- core_mem_swap_fwd (T : Type) : T → T → State → Result (State × Unit)
+ core.mem.swap_fwd (T : Type) : T → T → State → Result (State × Unit)
/- [core::mem::swap] -/
- core_mem_swap_back0
+ core.mem.swap_back0
(T : Type) : T → T → State → State → Result (State × T)
/- [core::mem::swap] -/
- core_mem_swap_back1
+ core.mem.swap_back1
(T : Type) : T → T → State → State → Result (State × T)
/- [core::num::nonzero::NonZeroU32::{14}::new] -/
- core_num_nonzero_non_zero_u32_new_fwd
+ core.num.nonzero.NonZeroU32.new_fwd
:
U32 → State → Result (State × (Option
core_num_nonzero_non_zero_u32_t))
/- [core::option::Option::{0}::unwrap] -/
- core_option_option_unwrap_fwd
+ core.option.Option.unwrap_fwd
(T : Type) : Option T → State → Result (State × T)
-end External
+end external
diff --git a/tests/lean/External/Types.lean b/tests/lean/External/Types.lean
index fda0670e..316f6474 100644
--- a/tests/lean/External/Types.lean
+++ b/tests/lean/External/Types.lean
@@ -2,8 +2,7 @@
-- [external]: type definitions
import Base
open Primitives
-
-namespace External
+namespace external
/- [core::num::nonzero::NonZeroU32] -/
axiom core_num_nonzero_non_zero_u32_t : Type
@@ -11,4 +10,4 @@ axiom core_num_nonzero_non_zero_u32_t : Type
/- The state type used in the state-error monad -/
axiom State : Type
-end External
+end external