packages feed

morley-1.0.0: test/Test/Interpreter/StackRef.hs

-- | Interpreter tests involving 'StackRef'.

module Test.Interpreter.StackRef
  ( test_mkStackRef
  ) where

import Test.Hspec.Expectations (shouldSatisfy)
import Test.Tasty (TestTree)
import Test.Tasty.HUnit (testCase)

import Michelson.Test (contractProp)
import Michelson.Test.Dummy (dummyContractEnv)
import Michelson.Typed

test_mkStackRef :: TestTree
test_mkStackRef =
  testCase "does not segfault" $
    contractProp contract (flip shouldSatisfy isRight . fst)
    dummyContractEnv () ()
  where
    stackRef = PrintComment . one . Right $ mkStackRef @1

    contract :: Contract 'TUnit 'TUnit
    contract =
      CAR `Seq` DUP `Seq` Ext (PRINT stackRef) `Seq`
      DROP `Seq` NIL `Seq` PAIR