0

My question is whether there are ways to test two IO actions in HSpec of Haskell?

Just something like the below example: (The below is wrong because of type)

  it "parse examples 0" $ liftM2 shouldBe (tests "ex0in.txt") (tests "ex0Out.txt")

  tests :: FileType -> IO (Either String String)
4

1 回答 1

3

I do not know FileType, I deal it equals FilePath.

use do and liftIO

it "parse examples 0" $ do
  ex0in <- liftIO (tests "ex0in.txt")
  ex0out <- liftIO (tests "ex0Out.txt")
  ex0in `shouldBe` ex0out

use join and liftIO

it "parse examples 0" $ join $ liftM2 shouldBe (liftIO (tests "ex0in.txt")) (liftIO (tests "ex0Out.txt"))
于 2018-06-30T04:57:47.440 回答