我的问题是,是否有办法在Haskell的HSpec中测试两个IO actions
?
就像下面的例子一样((由于类型,下面是错误的)
it "parse examples 0" $ liftM2 shouldBe (tests "ex0in.txt") (tests "ex0Out.txt")
tests :: FileType -> IO (Either String String)
答案 0 :(得分:3)
我不知道FileType
,我认为它等于FilePath
。
it "parse examples 0" $ do
ex0in <- liftIO (tests "ex0in.txt")
ex0out <- liftIO (tests "ex0Out.txt")
ex0in `shouldBe` ex0out
it "parse examples 0" $ join $ liftM2 shouldBe (liftIO (tests "ex0in.txt")) (liftIO (tests "ex0Out.txt"))