morley-0.4.0: test/Test/Lorentz/Macro.hs
-- | Tests for Lorentz macros.
--
-- They test logic of macros and type-level logic. Also they serve as
-- examples of using complex macros (e. g. parameterized with
-- type-level numbers)
module Test.Lorentz.Macro
( unit_duupX
, test_execute
) where
import Prelude hiding (drop, swap)
import Test.HUnit (Assertion, (@?=))
import Test.Tasty (TestTree)
import Test.Tasty.HUnit (testCase)
import Lorentz
import Michelson.Test.Dummy
unit_duupX :: Assertion
unit_duupX = do
duupX @1 @?= dup
duupX @2 @?= (dip dup # swap)
duupX @3 @?= duupX3
where
duupX3 :: [Bool, Integer, (), Bool] :-> [(), Bool, Integer, (), Bool]
duupX3 = dipN @2 dup # dig @2
test_execute :: [TestTree]
test_execute =
[ testCase "Two arguments lambda" $
let lam :: [Integer, Integer] :-> [(), Integer]
lam = add # unit
code = push 3 # push lam # execute # drop @()
in interpretLorentzLambda dummyContractEnv code 5
@?= Right 8
, testCase "Zero arguments lambda" $
let lam :: '[] :-> '[Integer]
lam = push 5
code = drop # push lam # execute
in interpretLorentzLambda dummyContractEnv code (0 :: Integer)
@?= Right 5
]