-- SPDX-FileCopyrightText: 2022 Oxhead Alpha
-- SPDX-License-Identifier: LicenseRef-MIT-OA

-- | Utility functions for checking predicates on contract's entrypoints for
-- Lorentz
module Test.Cleveland.Lorentz.Entrypoints
  ( -- * Entrypoint spec passed on the type level
    testContractCoversEntrypointsT
  , testContractMatchesEntrypointsT

    -- * Entrypoint spec passed as a value
  , testContractCoversEntrypoints
  , testContractMatchesEntrypoints
  ) where

import Test.Tasty (TestName)

import Lorentz (NiceParameterFull)
import Test.Cleveland.Lorentz.Internal.Entrypoints
import Test.Cleveland.Michelson.Internal.Entrypoints (ignoreExtraEntrypoints)

-- | Expect the contract to cover or exactly match with the entrypoints given in spec passed as the
-- first type argument. Checks both the contract type and the contract itself (when represented as
-- an untyped Michelson contract).
testContractCoversEntrypointsT,
  testContractMatchesEntrypointsT :: forall exp. TestName -> ContractEPTypeTest exp
testContractCoversEntrypointsT :: forall exp. TestName -> ContractEPTypeTest exp
testContractCoversEntrypointsT = forall expectedEps.
(EPMismatch -> EPMismatch)
-> TestName -> ContractEPTypeTest expectedEps
testCompareContractEntrypointsT @exp EPMismatch -> EPMismatch
ignoreExtraEntrypoints
testContractMatchesEntrypointsT :: forall exp. TestName -> ContractEPTypeTest exp
testContractMatchesEntrypointsT = forall expectedEps.
(EPMismatch -> EPMismatch)
-> TestName -> ContractEPTypeTest expectedEps
testCompareContractEntrypointsT @exp EPMismatch -> EPMismatch
forall a. a -> a
id

-- | Expect the contract to cover or exactly match with the entrypoints given in spec passed as a
-- 'Map' of names to types. Checks both the contract type and the contract itself (when represented as
-- an untyped Michelson contract).
testContractCoversEntrypoints,
  testContractMatchesEntrypoints :: NiceParameterFull contractEps => TestName -> ContractEPTest contractEps st vd
testContractCoversEntrypoints :: forall contractEps st vd.
NiceParameterFull contractEps =>
TestName -> ContractEPTest contractEps st vd
testContractCoversEntrypoints = (EPMismatch -> EPMismatch)
-> TestName -> ContractEPTest contractEps st vd
forall contractEps st vd.
NiceParameterFull contractEps =>
(EPMismatch -> EPMismatch)
-> TestName -> ContractEPTest contractEps st vd
testCompareContractEntrypoints EPMismatch -> EPMismatch
ignoreExtraEntrypoints
testContractMatchesEntrypoints :: forall contractEps st vd.
NiceParameterFull contractEps =>
TestName -> ContractEPTest contractEps st vd
testContractMatchesEntrypoints = (EPMismatch -> EPMismatch)
-> TestName -> ContractEPTest contractEps st vd
forall contractEps st vd.
NiceParameterFull contractEps =>
(EPMismatch -> EPMismatch)
-> TestName -> ContractEPTest contractEps st vd
testCompareContractEntrypoints EPMismatch -> EPMismatch
forall a. a -> a
id