summaryrefslogtreecommitdiff
path: root/tests/lean/misc-external/External
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--tests/lean/misc-external/External/ExternalFuns.lean5
-rw-r--r--tests/lean/misc-external/External/Funs.lean35
-rw-r--r--tests/lean/misc-external/External/Opaque.lean3
3 files changed, 19 insertions, 24 deletions
diff --git a/tests/lean/misc-external/External/ExternalFuns.lean b/tests/lean/misc-external/External/ExternalFuns.lean
new file mode 100644
index 00000000..6bd4f4a9
--- /dev/null
+++ b/tests/lean/misc-external/External/ExternalFuns.lean
@@ -0,0 +1,5 @@
+import Base.Primitives
+import External.Types
+import External.Opaque
+
+def opaque_defs : OpaqueDefs := sorry
diff --git a/tests/lean/misc-external/External/Funs.lean b/tests/lean/misc-external/External/Funs.lean
index 4e1f36a1..eeb83989 100644
--- a/tests/lean/misc-external/External/Funs.lean
+++ b/tests/lean/misc-external/External/Funs.lean
@@ -2,9 +2,7 @@
-- [external]: function definitions
import Base.Primitives
import External.Types
-import External.Opaque
-
-section variable (opaque_defs: OpaqueDefs)
+import External.ExternalFuns
/- [external::swap] -/
def swap_fwd
@@ -28,9 +26,7 @@ def swap_back
/- [external::test_new_non_zero_u32] -/
def test_new_non_zero_u32_fwd
- (x : UInt32) (st : State) :
- Result (State × core_num_nonzero_non_zero_u32_t)
- :=
+ (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
@@ -39,13 +35,10 @@ def test_new_non_zero_u32_fwd
/- [external::test_vec] -/
def test_vec_fwd : Result Unit :=
do
- let v := vec_new UInt32
- let _ ← vec_push_back UInt32 v (UInt32.ofNatCore 0 (by intlit))
+ let v := vec_new U32
+ let _ ← vec_push_back U32 v (U32.ofInt 0 (by intlit))
Result.ret ()
-/- Unit test for [external::test_vec] -/
-#assert (test_vec_fwd == .ret ())
-
/- [external::custom_swap] -/
def custom_swap_fwd
(T : Type) (x : T) (y : T) (st : State) : Result (State × T) :=
@@ -68,26 +61,24 @@ def custom_swap_back
/- [external::test_custom_swap] -/
def test_custom_swap_fwd
- (x : UInt32) (y : UInt32) (st : State) : Result (State × Unit) :=
+ (x : U32) (y : U32) (st : State) : Result (State × Unit) :=
do
- let (st0, _) ← custom_swap_fwd UInt32 x y st
+ let (st0, _) ← custom_swap_fwd U32 x y st
Result.ret (st0, ())
/- [external::test_custom_swap] -/
def test_custom_swap_back
- (x : UInt32) (y : UInt32) (st : State) (st0 : State) :
- Result (State × (UInt32 × UInt32))
+ (x : U32) (y : U32) (st : State) (st0 : State) :
+ Result (State × (U32 × U32))
:=
- custom_swap_back UInt32 x y st (UInt32.ofNatCore 1 (by intlit)) st0
+ custom_swap_back U32 x y st (U32.ofInt 1 (by intlit)) st0
/- [external::test_swap_non_zero] -/
-def test_swap_non_zero_fwd
- (x : UInt32) (st : State) : Result (State × UInt32) :=
+def test_swap_non_zero_fwd (x : U32) (st : State) : Result (State × U32) :=
do
- let (st0, _) ← swap_fwd UInt32 x (UInt32.ofNatCore 0 (by intlit)) st
- let (st1, (x0, _)) ←
- swap_back UInt32 x (UInt32.ofNatCore 0 (by intlit)) st st0
- if h: x0 = (UInt32.ofNatCore 0 (by intlit))
+ let (st0, _) ← swap_fwd U32 x (U32.ofInt 0 (by intlit)) st
+ let (st1, (x0, _)) ← swap_back U32 x (U32.ofInt 0 (by intlit)) st st0
+ if h: x0 = (U32.ofInt 0 (by intlit))
then Result.fail Error.panic
else Result.ret (st1, x0)
diff --git a/tests/lean/misc-external/External/Opaque.lean b/tests/lean/misc-external/External/Opaque.lean
index d3582de3..d641912b 100644
--- a/tests/lean/misc-external/External/Opaque.lean
+++ b/tests/lean/misc-external/External/Opaque.lean
@@ -19,8 +19,7 @@ structure OpaqueDefs where
/- [core::num::nonzero::NonZeroU32::{14}::new] -/
core_num_nonzero_non_zero_u32_new_fwd
:
- UInt32 -> State -> Result (State × (Option
- core_num_nonzero_non_zero_u32_t))
+ U32 -> State -> Result (State × (Option core_num_nonzero_non_zero_u32_t))
/- [core::option::Option::{0}::unwrap] -/
core_option_option_unwrap_fwd