Skip to content

Commit

Permalink
Add injection tests
Browse files Browse the repository at this point in the history
  • Loading branch information
garyb committed Nov 30, 2018
1 parent 2a0a652 commit 772bc67
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions test/Main.purs
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,22 @@ module Test.Main where

import Prelude

import Data.Const (Const)
import Data.Functor.Compose (Compose(..))
import Data.Functor.Coproduct (Coproduct, left, right)
import Data.Functor.Coproduct.Inject (inj)
import Data.Identity (Identity(..))
import Data.Maybe (Maybe(..))
import Effect (Effect)
import Test.Assert (assertEqual)

main :: Effect Unit
main = do
testComposeOrdering
testInjections

testComposeOrdering :: Effect Unit
testComposeOrdering = do
assertEqual
{ expected: Compose (Identity (Just true))
, actual: Compose (Identity (Just true))
Expand All @@ -18,3 +26,18 @@ main = do
{ expected: Compose (Identity (Just true)) > Compose (Identity (Just false))
, actual: true
}

testInjections :: Effect Unit
testInjections = do
assertEqual
{ expected: Identity unit
, actual: inj (Identity unit)
}
assertEqual
{ expected: left (Identity unit) :: Coproduct Identity (Const Void) Unit
, actual: inj (Identity unit)
}
assertEqual
{ expected: right (Identity unit) :: Coproduct (Const Void) Identity Unit
, actual: inj (Identity unit)
}

0 comments on commit 772bc67

Please sign in to comment.