packages feed

cleveland-0.1.0: lorentz-test/Test/Lorentz/ReferencedByName.hs

-- SPDX-FileCopyrightText: 2020 Tocqueville Group
--
-- SPDX-License-Identifier: LicenseRef-MIT-TQ

-- | Tests for 'Lorentz.NameReferenced' module.
--
-- They test logic of macros in that module and type-level logic,
-- and serve as examples of their use.

module Test.Lorentz.ReferencedByName
  ( test_dupL
  ) where

import Lorentz
import Prelude hiding (drop, swap)

import Test.HUnit (Assertion, (@?=))
import Test.Tasty (TestTree)
import Test.Tasty.HUnit (testCase)

import Morley.Michelson.Typed

-- | Compare instructions on their untyped representation.
--
-- Necessary to exclude @Nop@s.
(@?~=) :: a :-> b -> a :-> b -> Assertion
(@?~=) = (@?=) `on` (instrToOps . iAnyCode)
infix 1 @?~=

test_dupL :: [TestTree]
test_dupL =
  [ testCase "Duplicating third element" $
      stackType @[(), "a" :! Integer, "b" :! Natural] # dupL #b
        @?~= dupN @3 # fromNamed #b
  ]